From a1b531ff0cdce6bdfc569c7b8f9d2e7e589a4cd6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 12:23:41 +0000 Subject: [PATCH 001/112] Auto-generated commit 667e9cbf7c6968b7bec95ad87c827ffafc4eb485 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 331 ++++++ index.d.ts | 305 ++++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 43 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3883 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..f710f0d --- /dev/null +++ b/README.md @@ -0,0 +1,331 @@ + + +# Strided Array Stream + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create a [readable stream][readable-stream] from a strided array-like object. + + + +
+ +## Usage + +```javascript +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +``` + + + +#### stridedArrayStream( N, buffer, stride, offset\[, options] ) + +Returns a [readable stream][readable-stream] from a strided array-like `object`. + +```javascript +import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; + +function log( chunk ) { + console.log( chunk.toString() ); +} + +var stream = stridedArrayStream( 4, [ 1, 2, 3, 4 ], 1, 0 ); +var iStream = inspectStream( log ); + +stream.pipe( iStream ); +``` + +The function accepts the following `options`: + +- **objectMode**: specifies whether a [stream][stream] should operate in [objectMode][object-mode]. Default: `false`. +- **encoding**: specifies how `Buffer` objects should be decoded to `strings`. Default: `null`. +- **highWaterMark**: specifies the maximum number of bytes to store in an internal buffer before pausing streaming. +- **sep**: separator used to join streamed data. This option is only applicable when a stream is **not** in [objectMode][object-mode]. Default: `'\n'`. +- **serialize**: custom serialization function. This option is only applicable when a stream is **not** in [objectMode][object-mode]. + +To set [stream][stream] `options`, + +```javascript +var opts = { + 'objectMode': true, + 'encoding': 'utf8', + 'highWaterMark': 64 +}; + +var stream = stridedArrayStream( 4, [ 1, 2, 3, 4 ], 1, 0, opts ); +``` + +By default, when not operating in [objectMode][object-mode], a returned [stream][stream] delineates individual values using a newline character. To specify an alternative separator, set the `sep` option. + +```javascript +import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; + +function log( chunk ) { + console.log( chunk.toString() ); +} + +var stream = stridedArrayStream( 4, [ 1, 2, 3, 4 ], 1, 0, { + 'sep': ',' +}); + +var iStream = inspectStream( log ); + +stream.pipe( iStream ); +``` + +By default, when not operating in [objectMode][object-mode], a returned [stream][stream] serializes values as JSON strings. To specify custom serialization behavior (either to a `string` or `Buffer`), set the `serialize` option. + +```javascript +import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; + +function serialize( v ) { + return 'v::' + v.toString(); +} + +function log( chunk ) { + console.log( chunk.toString() ); +} + +var stream = stridedArrayStream( 4, [ 1, 2, 3, 4 ], 1, 0, { + 'serialize': serialize +}); + +var iStream = inspectStream( log ); + +stream.pipe( iStream ); +``` + +* * * + +#### stridedArrayStream.factory( \[options] ) + +Returns a `function` for creating [readable streams][readable-stream] from strided array-like objects. + +```javascript +var opts = { + 'objectMode': true, + 'encoding': 'utf8', + 'highWaterMark': 64 +}; + +var createStream = stridedArrayStream.factory( opts ); + +var stream1 = createStream( 2, [ 1, 2, 3, 4 ], 2, 1 ); +var stream2 = createStream( 3, [ 5, 6, 7, 8 ], 1, 1 ); +// ... +``` + +The method accepts the same `options` as [`stridedArrayStream()`](#strided-array-stream). + +* * * + +#### stridedArrayStream.objectMode( N, buffer, stride, offset\[, options] ) + +This method is a convenience function to create [streams][stream] which **always** operate in [objectMode][object-mode]. + +```javascript +import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; + +function log( v ) { + console.log( v ); +} + +var stream = stridedArrayStream.objectMode( 4, [ 1, 2, 3, 4 ], 1, 0 ); + +var opts = { + 'objectMode': true +}; +var iStream = inspectStream( opts, log ); + +stream.pipe( iStream ); +``` + +This method accepts the same `options` as [`stridedArrayStream()`](#strided-array-stream); however, the method will **always** override the [`objectMode`][object-mode] option in `options`. + +
+ + + +* * * + +
+ +## Notes + +- In [`objectMode`][object-mode], `null` is a reserved value. If an `array` contains `null` values (e.g., as a means to encode missing values), the stream will prematurely end. Consider an alternative encoding or filter `null` values prior to invocation. +- In binary mode, if an `array` contains `undefined` values, the stream will emit an error. Consider providing a custom serialization function or filtering `undefined` values prior to invocation. + +
+ + + +* * * + +
+ +## 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..3bf1250 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,305 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/// +/// + +import { Readable } from 'stream'; +import { Collection } from '@stdlib/types/object'; + +/** +* Interface defining stream options. +*/ +interface Options { + /** + * Specifies whether a stream should operate in object mode (default: `false`). + */ + objectMode?: boolean; + + /** + * Specifies how `Buffer` objects should be decoded to strings (default: `null`). + */ + encoding?: string | null; + + /** + * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. + */ + highWaterMark?: number; + + /** + * Separator used to join streamed data (default: `'\n'`). + */ + sep?: string; + + /** + * Custom serialization function. + */ + serialize?: Function; +} + +/** +* Interface defining a stream constructor which is both "newable" and "callable". +*/ +interface Constructor { + /** + * Stream constructor for generating a readable stream from an array-like object. + * + * @param N - number of values to stream + * @param buffer - source value + * @param stride - stride length + * @param offset - starting index + * @param options - stream options + * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) + * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) + * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming + * @param options.sep - separator used to join streamed data (default: '\n') + * @param options.serialize - custom serialization function + * @throws first argument must be a nonnegative integer + * @throws third argument must be an integer + * @throws fourth argument must be a nonnegative integer + * @throws linear index cannot exceed array bounds + * @throws options argument must be an object + * @throws must provide valid options + * @returns stream instance + * + * @example + * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); + * var Float64Array = require( `@stdlib/array/float64` ); + * var randu = require( `@stdlib/random/base/randu` ); + * + * function log( chunk ) { + * console.log( chunk.toString() ); + * } + * + * var arr = new Float64Array( 10 ); + * var i; + * for ( i = 0; i < arr.length; i++ ) { + * arr[ i ] = randu(); + * } + * + * var StridedArrayStream = stridedArrayStream; + * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); + * + * stream.pipe( inspectStream( log ) ); + */ + new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable + + /** + * Stream constructor for generating a readable stream from an array-like object. + * + * @param N - number of values to stream + * @param buffer - source value + * @param stride - stride length + * @param offset - starting index + * @param options - stream options + * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) + * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) + * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming + * @param options.sep - separator used to join streamed data (default: '\n') + * @param options.serialize - custom serialization function + * @throws first argument must be a nonnegative integer + * @throws second argument must be an array-like object + * @throws third argument must be an integer + * @throws fourth argument must be a nonnegative integer + * @throws linear index cannot exceed array bounds + * @throws options argument must be an object + * @throws must provide valid options + * @returns stream instance + * + * @example + * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); + * var Float64Array = require( `@stdlib/array/float64` ); + * var randu = require( `@stdlib/random/base/randu` ); + * + * function log( chunk ) { + * console.log( chunk.toString() ); + * } + * + * var arr = new Float64Array( 10 ); + * var i; + * for ( i = 0; i < arr.length; i++ ) { + * arr[ i ] = randu(); + * } + * + * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); + * + * stream.pipe( inspectStream( log ) ); + */ + ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable + + /** + * Returns a function for creating readable streams from strided array-like values. + * + * @param options - stream options + * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) + * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) + * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming + * @param options.sep - separator used to join streamed data (default: '\n') + * @param options.serialize - custom serialization function + * @returns stream factory + * + * @example + * var Float64Array = require( `@stdlib/array/float64` ); + * var randu = require( `@stdlib/random/base/randu` ); + * + * var arr = new Float64Array( 10 ); + * var i; + * for ( i = 0; i < arr.length; i++ ) { + * arr[ i ] = randu(); + * } + * + * var opts = { + * 'sep': ',', + * 'objectMode': false, + * 'encoding': 'utf8', + * 'highWaterMark': 64 + * }; + * + * var createStream = stridedArrayStream.factory( opts ); + * + * // Create 10 identically configured streams... + * var streams = []; + * for ( i = 0; i < 10; i++ ) { + * streams.push( createStream( arr.length, arr, 1, 0 ) ); + * } + */ + factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length + + /** + * Returns an "objectMode" readable stream from an array-like value. + * + * @param N - number of values to stream + * @param buffer - source value + * @param stride - stride length + * @param offset - starting index + * @param options - stream options + * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) + * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming + * @throws first argument must be a nonnegative integer + * @throws second argument must be an array-like object + * @throws third argument must be an integer + * @throws fourth argument must be a nonnegative integer + * @throws options argument must be an object + * @throws must provide valid options + * @returns stream instance + * + * @example + * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); + * var Float64Array = require( `@stdlib/array/float64` ); + * var randu = require( `@stdlib/random/base/randu` ); + * + * function log( v ) { + * console.log( v ); + * } + * + * var arr = new Float64Array( 10 ); + * var i; + * for ( i = 0; i < arr.length; i++ ) { + * arr[ i ] = randu(); + * } + * + * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); + * + * stream.pipe( inspectStream.objectMode( log ) ); + */ + objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length +} + +/** +* Creates a readable stream from a strided array-like object. +* +* @param N - number of values to stream +* @param buffer - source value +* @param stride - stride length +* @param offset - starting index +* @param options - stream options +* @throws must provide valid options +* @returns stream instance +* +* @example +* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); +* var Float64Array = require( `@stdlib/array/float64` ); +* var randu = require( `@stdlib/random/base/randu` ); +* +* function log( chunk ) { +* console.log( chunk.toString() ); +* } +* +* var arr = new Float64Array( 10 ); +* var i; +* for ( i = 0; i < arr.length; i++ ) { +* arr[ i ] = randu(); +* } +* +* var StridedArrayStream = stridedArrayStream; +* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); +* +* stream.pipe( inspectStream( log ) ); +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* var randu = require( `@stdlib/random/base/randu` ); +* +* var arr = new Float64Array( 10 ); +* var i; +* for ( i = 0; i < arr.length; i++ ) { +* arr[ i ] = randu(); +* } +* +* var opts = { +* 'sep': ',', +* 'objectMode': false, +* 'encoding': 'utf8', +* 'highWaterMark': 64 +* }; +* +* var createStream = stridedArrayStream.factory( opts ); +* +* // Create 10 identically configured streams... +* var streams = []; +* for ( i = 0; i < 10; i++ ) { +* streams.push( createStream( arr.length, arr, 1, 0 ) ); +* } +* +* @example +* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); +* var Float64Array = require( `@stdlib/array/float64` ); +* var randu = require( `@stdlib/random/base/randu` ); +* +* function log( v ) { +* console.log( v ); +* } +* +* var arr = new Float64Array( 10 ); +* var i; +* for ( i = 0; i < arr.length; i++ ) { +* arr[ i ] = randu(); +* } +* +* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); +* +* stream.pipe( inspectStream.objectMode( log ) ); +*/ +declare var stridedArrayStream: Constructor; + + +// EXPORTS // + +export = stridedArrayStream; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dd22c4e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function v(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})})),t}var w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function y(){throw new Error("setTimeout has not been defined")}function x(){throw new Error("clearTimeout has not been defined")}var _=y,T=x;function M(e){if(_===setTimeout)return setTimeout(e,0);if((_===y||!_)&&setTimeout)return _=setTimeout,setTimeout(e,0);try{return _(e,0)}catch(t){try{return _.call(null,e,0)}catch(t){return _.call(this,e,0)}}}"function"==typeof w.setTimeout&&(_=setTimeout),"function"==typeof w.clearTimeout&&(T=clearTimeout);var E,O=[],k=!1,z=-1;function P(){k&&E&&(k=!1,E.length?O=E.concat(O):z=-1,O.length&&S())}function S(){if(!k){var e=M(P);k=!0;for(var t=O.length;t;){for(E=O,O=[];++z1)for(var r=1;r4?new ve(e,t,r,i,s):new ve(e,t,r,i);if(!de(e))throw new TypeError(fe("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!se(t))throw new TypeError(fe("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(!ae(r))throw new TypeError(fe("invalid argument. Third argument must be an integer. Value: `%s`.",r));if(!de(i))throw new TypeError(fe("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",i));if(e>0&&(a=i+(e-1)*r,i>=t.length||a<0||a>=t.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(n=le(ge),arguments.length>4&&(o=be(n,s)))throw o;return je("Creating a readable stream configured with the following options: %s.",JSON.stringify(n)),ie.call(this,n),ue(this,"_destroyed",!1),me(this,"_objectMode",n.objectMode),me(this,"_sep",n.sep),me(this,"_serialize",n.serialize||JSON.stringify),me(this,"_buffer",t),me(this,"_N",e),me(this,"_stride",r),me(this,"_offset",i),ue(this,"_idx",i),ue(this,"_i",0),this}a(ve,ie),me(ve.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return je("Finished iteration."),this.push(null);r=this._buffer[this._idx],je("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?he(r):he(this._sep+r):oe(r)?this._i>1&&(r=pe.concat([he(this._sep),r])):t=new Error(fe("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),me(ve.prototype,"destroy",(function(e){var t;return this._destroyed?(je("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,ce((function(){e&&(je("Stream was destroyed due to an error. Error: %s.",ne(e)?e.message:JSON.stringify(e)),t.emit("error",e));je("Closing the stream..."),t.emit("close")})),this)}));var we=p,ye=m,xe=o,_e=ve;var Te=o,Me=ve;var Ee=e,Oe=ve,ke=function(e,t,r,i,s){var n;if(arguments.length>4){if(!we(n=s))throw new TypeError(ye("invalid argument. Options argument must be an object. Value: `%s`.",n));n=xe(s,1)}else n={};return n.objectMode=!0,new _e(e,t,r,i,n)},ze=function(e){var t;return t=arguments.length?Te(e,1):{},r;function r(e,r,i,s){return new Me(e,r,i,s,t)}};Ee(Oe,"objectMode",ke),Ee(Oe,"factory",ze);var Pe=Oe;export{Pe as default,ze as factory,ke as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e25c80b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/readable.js","../lib/validate.js","../node_modules/debug/src/index.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["var Stream = require('stream');\nif (process.env.READABLE_STREAM === 'disable' && Stream) {\n module.exports = Stream;\n exports = module.exports = Stream.Readable;\n exports.Readable = Stream.Readable;\n exports.Writable = Stream.Writable;\n exports.Duplex = Stream.Duplex;\n exports.Transform = Stream.Transform;\n exports.PassThrough = Stream.PassThrough;\n exports.Stream = Stream;\n} else {\n exports = module.exports = require('./lib/_stream_readable.js');\n exports.Stream = Stream || exports;\n exports.Readable = exports;\n exports.Writable = require('./lib/_stream_writable.js');\n exports.Duplex = require('./lib/_stream_duplex.js');\n exports.Transform = require('./lib/_stream_transform.js');\n exports.PassThrough = require('./lib/_stream_passthrough.js');\n}\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n","/**\n * Detect Electron renderer process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process !== 'undefined' && process.type === 'renderer') {\n module.exports = require('./browser.js');\n} else {\n module.exports = require('./node.js');\n}\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar copy = require( '@stdlib/utils-copy' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar copy = require( '@stdlib/utils-copy' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar copy = require( '@stdlib/utils-copy' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar stream = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = stream;\n"],"names":["Stream","require","process","env","READABLE_STREAM","module","exports","Readable","Writable","Duplex","Transform","PassThrough","isObject","require$$0","hasOwnProp","require$$1","isBoolean","require$$2","isPrimitive","isNonNegative","require$$3","isString","require$$4","isFunction","require$$5","format","require$$6","validate_1","opts","options","sep","TypeError","objectMode","encoding","highWaterMark","serialize","type","debug_1","logger","isCollection","isError","isBuffer","isInteger","isNonNegativeInteger","copy","setNonEnumerable","require$$8","setNonEnumerableReadOnly","require$$9","string2buffer","require$$10","Buffer","require$$11","require$$12","nextTick","require$$13","DEFAULTS","require$$14","validate","require$$15","debug","require$$16","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","RangeError","JSON","stringify","call","require$$7","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","_sep","concat","Error","emit","error","self","message","setReadOnly","stream","factory","createStream","lib"],"mappings":"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"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4214b37 --- /dev/null +++ b/package.json @@ -0,0 +1,43 @@ +{ + "name": "@stdlib/streams-node-from-strided-array", + "version": "0.0.0", + "description": "Create a readable stream from a strided array-like object.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/streams-node-from-strided-array.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "utilities", + "utility", + "utils", + "util", + "node", + "stream", + "streams", + "readable", + "array", + "array-like", + "typed array", + "typed", + "strided", + "ndarray", + "multidimensional", + "view", + "from", + "string", + "convert", + "to" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..57e224e --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 25616b3cde87bcb1f7b753dfa2bdc37b468f7d53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:34:03 +0000 Subject: [PATCH 002/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 0a779a9..fc09752 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From 77ed98051dddcbacf3499ec7b45b158c4a91db4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 21:14:29 +0000 Subject: [PATCH 003/112] Remove files --- index.d.ts | 305 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2999 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dd22c4e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function v(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})})),t}var w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function y(){throw new Error("setTimeout has not been defined")}function x(){throw new Error("clearTimeout has not been defined")}var _=y,T=x;function M(e){if(_===setTimeout)return setTimeout(e,0);if((_===y||!_)&&setTimeout)return _=setTimeout,setTimeout(e,0);try{return _(e,0)}catch(t){try{return _.call(null,e,0)}catch(t){return _.call(this,e,0)}}}"function"==typeof w.setTimeout&&(_=setTimeout),"function"==typeof w.clearTimeout&&(T=clearTimeout);var E,O=[],k=!1,z=-1;function P(){k&&E&&(k=!1,E.length?O=E.concat(O):z=-1,O.length&&S())}function S(){if(!k){var e=M(P);k=!0;for(var t=O.length;t;){for(E=O,O=[];++z1)for(var r=1;r4?new ve(e,t,r,i,s):new ve(e,t,r,i);if(!de(e))throw new TypeError(fe("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!se(t))throw new TypeError(fe("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(!ae(r))throw new TypeError(fe("invalid argument. Third argument must be an integer. Value: `%s`.",r));if(!de(i))throw new TypeError(fe("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",i));if(e>0&&(a=i+(e-1)*r,i>=t.length||a<0||a>=t.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(n=le(ge),arguments.length>4&&(o=be(n,s)))throw o;return je("Creating a readable stream configured with the following options: %s.",JSON.stringify(n)),ie.call(this,n),ue(this,"_destroyed",!1),me(this,"_objectMode",n.objectMode),me(this,"_sep",n.sep),me(this,"_serialize",n.serialize||JSON.stringify),me(this,"_buffer",t),me(this,"_N",e),me(this,"_stride",r),me(this,"_offset",i),ue(this,"_idx",i),ue(this,"_i",0),this}a(ve,ie),me(ve.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return je("Finished iteration."),this.push(null);r=this._buffer[this._idx],je("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?he(r):he(this._sep+r):oe(r)?this._i>1&&(r=pe.concat([he(this._sep),r])):t=new Error(fe("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),me(ve.prototype,"destroy",(function(e){var t;return this._destroyed?(je("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,ce((function(){e&&(je("Stream was destroyed due to an error. Error: %s.",ne(e)?e.message:JSON.stringify(e)),t.emit("error",e));je("Closing the stream..."),t.emit("close")})),this)}));var we=p,ye=m,xe=o,_e=ve;var Te=o,Me=ve;var Ee=e,Oe=ve,ke=function(e,t,r,i,s){var n;if(arguments.length>4){if(!we(n=s))throw new TypeError(ye("invalid argument. Options argument must be an object. Value: `%s`.",n));n=xe(s,1)}else n={};return n.objectMode=!0,new _e(e,t,r,i,n)},ze=function(e){var t;return t=arguments.length?Te(e,1):{},r;function r(e,r,i,s){return new Me(e,r,i,s,t)}};Ee(Oe,"objectMode",ke),Ee(Oe,"factory",ze);var Pe=Oe;export{Pe as default,ze as factory,ke as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e25c80b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/readable.js","../lib/validate.js","../node_modules/debug/src/index.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["var Stream = require('stream');\nif (process.env.READABLE_STREAM === 'disable' && Stream) {\n module.exports = Stream;\n exports = module.exports = Stream.Readable;\n exports.Readable = Stream.Readable;\n exports.Writable = Stream.Writable;\n exports.Duplex = Stream.Duplex;\n exports.Transform = Stream.Transform;\n exports.PassThrough = Stream.PassThrough;\n exports.Stream = Stream;\n} else {\n exports = module.exports = require('./lib/_stream_readable.js');\n exports.Stream = Stream || exports;\n exports.Readable = exports;\n exports.Writable = require('./lib/_stream_writable.js');\n exports.Duplex = require('./lib/_stream_duplex.js');\n exports.Transform = require('./lib/_stream_transform.js');\n exports.PassThrough = require('./lib/_stream_passthrough.js');\n}\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n","/**\n * Detect Electron renderer process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process !== 'undefined' && process.type === 'renderer') {\n module.exports = require('./browser.js');\n} else {\n module.exports = require('./node.js');\n}\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar copy = require( '@stdlib/utils-copy' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar copy = require( '@stdlib/utils-copy' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar copy = require( '@stdlib/utils-copy' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar stream = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = stream;\n"],"names":["Stream","require","process","env","READABLE_STREAM","module","exports","Readable","Writable","Duplex","Transform","PassThrough","isObject","require$$0","hasOwnProp","require$$1","isBoolean","require$$2","isPrimitive","isNonNegative","require$$3","isString","require$$4","isFunction","require$$5","format","require$$6","validate_1","opts","options","sep","TypeError","objectMode","encoding","highWaterMark","serialize","type","debug_1","logger","isCollection","isError","isBuffer","isInteger","isNonNegativeInteger","copy","setNonEnumerable","require$$8","setNonEnumerableReadOnly","require$$9","string2buffer","require$$10","Buffer","require$$11","require$$12","nextTick","require$$13","DEFAULTS","require$$14","validate","require$$15","debug","require$$16","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","RangeError","JSON","stringify","call","require$$7","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","_sep","concat","Error","emit","error","self","message","setReadOnly","stream","factory","createStream","lib"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 57e224e..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 61513755a2eb919b751188ac2eeb5aae97cd8eeb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 21:15:21 +0000 Subject: [PATCH 004/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 --- branches.md | 53 - docs/repl.txt | 155 -- docs/types/test.ts | 189 -- examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 --- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 376 --- test/test.js | 43 - test/test.main.js | 1139 --------- test/test.object_mode.js | 279 --- test/test.validate.js | 241 -- 47 files changed, 2724 insertions(+), 6549 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 7403964..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:11:40.800Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c9730a4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..04bb0c7 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e4a000d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var stream = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( stream, 'objectMode', objectMode ); -setReadOnly( stream, 'factory', factory ); - - -// EXPORTS // - -module.exports = stream; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fc09752..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..596c0c9 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 354c741226a3046fd74f651346704706b7f7068b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:38:08 +0000 Subject: [PATCH 005/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 0a779a9..fc09752 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From dd0d41ecdd2364fc27bb794161f2c398005fc897 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:06:40 +0000 Subject: [PATCH 006/112] Remove files --- index.d.ts | 305 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2999 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c9730a4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 04bb0c7..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":";;2gIAyBIA,EAAMC,QAAQ,wBAGlBC,OAAOC,QAAUC,GAGjB,IAIIC,EAJAC,EAAUL,QAAQ,WAOtBG,GAASG,cAAgBA,GAGhBN,QAAQ,UAAUO,aAE3B,IAAIC,EAAkB,SAAUC,EAASC,GACvC,OAAOD,EAAQE,UAAUD,GAAME,QAK7BC,EAASb,QAAQ,6BAKjBc,EAASd,QAAQ,eAAec,OAChCC,EAAgBC,EAAOC,YAAc,aAWzC,IAAIC,EAAOC,OAAOC,OAAOpB,QAAQ,iBACjCkB,EAAKG,SAAWrB,QAAQ,YAIxB,IAAIsB,GAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,IAAaA,GAAUE,SACjBF,GAAUE,SAAS,UAEnB,aAIV,IAEIC,GAFAC,GAAa1B,QAAQ,iCACrB2B,GAAc3B,QAAQ,8BAG1BkB,EAAKG,SAASlB,GAAUU,GAExB,IAAIe,GAAe,CAAC,QAAS,QAAS,UAAW,QAAS,UAc1D,SAAStB,GAAcuB,EAASC,GAG9BD,EAAUA,GAAW,GAOrB,IAAIE,EAAWD,aATf1B,EAASA,GAAUJ,QAAQ,qBAa3BgC,KAAKC,aAAeJ,EAAQI,WAExBF,IAAUC,KAAKC,WAAaD,KAAKC,cAAgBJ,EAAQK,oBAI7D,IAAIC,EAAMN,EAAQO,cACdC,EAAcR,EAAQS,sBACtBC,EAAaP,KAAKC,WAAa,GAAK,MAElBD,KAAKI,cAAvBD,GAAe,IAARA,EAAgCA,EAAaJ,IAAaM,GAA+B,IAAhBA,GAAyCA,EAAsCE,EAGnKP,KAAKI,cAAgBI,KAAKC,MAAMT,KAAKI,eAKrCJ,KAAKU,OAAS,IAAIhB,GAClBM,KAAKpB,OAAS,EACdoB,KAAKW,MAAQ,KACbX,KAAKY,WAAa,EAClBZ,KAAKa,QAAU,KACfb,KAAKc,OAAQ,EACbd,KAAKe,YAAa,EAClBf,KAAKgB,SAAU,EAMfhB,KAAKiB,MAAO,EAIZjB,KAAKkB,cAAe,EACpBlB,KAAKmB,iBAAkB,EACvBnB,KAAKoB,mBAAoB,EACzBpB,KAAKqB,iBAAkB,EAGvBrB,KAAKsB,WAAY,EAKjBtB,KAAKuB,gBAAkB1B,EAAQ0B,iBAAmB,OAGlDvB,KAAKwB,WAAa,EAGlBxB,KAAKyB,aAAc,EAEnBzB,KAAK0B,QAAU,KACf1B,KAAK2B,SAAW,KACZ9B,EAAQ8B,WACLlC,KAAeA,GAAgBzB,QAAQ,mBAAmByB,eAC/DO,KAAK0B,QAAU,IAAIjC,GAAcI,EAAQ8B,UACzC3B,KAAK2B,SAAW9B,EAAQ8B,UAI5B,SAASxD,GAAS0B,GAGhB,GAFAzB,EAASA,GAAUJ,QAAQ,sBAErBgC,gBAAgB7B,IAAW,OAAO,IAAIA,GAAS0B,GAErDG,KAAK4B,eAAiB,IAAItD,GAAcuB,EAASG,MAGjDA,KAAK6B,UAAW,EAEZhC,IAC0B,mBAAjBA,EAAQiC,OAAqB9B,KAAK+B,MAAQlC,EAAQiC,MAE9B,mBAApBjC,EAAQmC,UAAwBhC,KAAKiC,SAAWpC,EAAQmC,UAGrEnD,EAAOqD,KAAKlC,MA2Dd,SAASmC,GAAiBrC,EAAQsC,EAAOT,EAAUU,EAAYC,GAC7D,IAKMC,EALFC,EAAQ1C,EAAO8B,eACL,OAAVQ,GACFI,EAAMxB,SAAU,EA0NpB,SAAoBlB,EAAQ0C,GAC1B,GAAIA,EAAM1B,MAAO,OACjB,GAAI0B,EAAMd,QAAS,CACjB,IAAIU,EAAQI,EAAMd,QAAQe,MACtBL,GAASA,EAAMxD,SACjB4D,EAAM9B,OAAOgC,KAAKN,GAClBI,EAAM5D,QAAU4D,EAAMvC,WAAa,EAAImC,EAAMxD,QAGjD4D,EAAM1B,OAAQ,EAGd6B,GAAa7C,GArOX8C,CAAW9C,EAAQ0C,KAGdF,IAAgBC,EA2CzB,SAAsBC,EAAOJ,GAC3B,IAAIG,EApPiBM,EAqPFT,EApPZtD,EAAOgE,SAASD,IAAQA,aAAe9D,GAoPA,iBAAVqD,QAAgCW,IAAVX,GAAwBI,EAAMvC,aACtFsC,EAAK,IAAIS,UAAU,oCAtPvB,IAAuBH,EAwPrB,OAAON,EAhDqBU,CAAaT,EAAOJ,IAC1CG,EACFzC,EAAOoD,KAAK,QAASX,GACZC,EAAMvC,YAAcmC,GAASA,EAAMxD,OAAS,GAChC,iBAAVwD,GAAuBI,EAAMvC,YAAcd,OAAOgE,eAAef,KAAWtD,EAAOsE,YAC5FhB,EAhNR,SAA6BA,GAC3B,OAAOtD,EAAOuE,KAAKjB,GA+MLkB,CAAoBlB,IAG1BC,EACEG,EAAMzB,WAAYjB,EAAOoD,KAAK,QAAS,IAAIK,MAAM,qCAA0CC,GAAS1D,EAAQ0C,EAAOJ,GAAO,GACrHI,EAAM1B,MACfhB,EAAOoD,KAAK,QAAS,IAAIK,MAAM,6BAE/Bf,EAAMxB,SAAU,EACZwB,EAAMd,UAAYC,GACpBS,EAAQI,EAAMd,QAAQ+B,MAAMrB,GACxBI,EAAMvC,YAA+B,IAAjBmC,EAAMxD,OAAc4E,GAAS1D,EAAQ0C,EAAOJ,GAAO,GAAYsB,GAAc5D,EAAQ0C,IAE7GgB,GAAS1D,EAAQ0C,EAAOJ,GAAO,KAGzBC,IACVG,EAAMxB,SAAU,IAIpB,OAgCF,SAAsBwB,GACpB,OAAQA,EAAM1B,QAAU0B,EAAMtB,cAAgBsB,EAAM5D,OAAS4D,EAAMpC,eAAkC,IAAjBoC,EAAM5D,QAjCnF+E,CAAanB,GAGtB,SAASgB,GAAS1D,EAAQ0C,EAAOJ,EAAOC,GAClCG,EAAM3B,SAA4B,IAAjB2B,EAAM5D,SAAiB4D,EAAMvB,MAChDnB,EAAOoD,KAAK,OAAQd,GACpBtC,EAAOgC,KAAK,KAGZU,EAAM5D,QAAU4D,EAAMvC,WAAa,EAAImC,EAAMxD,OACzCyD,EAAYG,EAAM9B,OAAOkD,QAAQxB,GAAYI,EAAM9B,OAAOgC,KAAKN,GAE/DI,EAAMtB,cAAcyB,GAAa7C,IAEvC4D,GAAc5D,EAAQ0C,GAvGxBrD,OAAO0E,eAAe1F,GAASiF,UAAW,YAAa,CACrDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAK4B,gBAGF5B,KAAK4B,eAAeN,WAE7ByC,IAAK,SAAUC,GAGRhE,KAAK4B,iBAMV5B,KAAK4B,eAAeN,UAAY0C,MAIpC7F,GAASiF,UAAUpB,QAAUrC,GAAYqC,QACzC7D,GAASiF,UAAUa,WAAatE,GAAYuE,UAC5C/F,GAASiF,UAAUnB,SAAW,SAAUkC,EAAKC,GAC3CpE,KAAK0C,KAAK,MACV0B,EAAGD,IAOLhG,GAASiF,UAAUV,KAAO,SAAUN,EAAOT,GACzC,IACIW,EADAE,EAAQxC,KAAK4B,eAgBjB,OAbKY,EAAMvC,WAUTqC,GAAiB,EATI,iBAAVF,KACTT,EAAWA,GAAYa,EAAMjB,mBACZiB,EAAMb,WACrBS,EAAQtD,EAAOuE,KAAKjB,EAAOT,GAC3BA,EAAW,IAEbW,GAAiB,GAMdH,GAAiBnC,KAAMoC,EAAOT,GAAU,EAAOW,IAIxDnE,GAASiF,UAAUQ,QAAU,SAAUxB,GACrC,OAAOD,GAAiBnC,KAAMoC,EAAO,MAAM,GAAM,IAwEnDjE,GAASiF,UAAUiB,SAAW,WAC5B,OAAuC,IAAhCrE,KAAK4B,eAAef,SAI7B1C,GAASiF,UAAUkB,YAAc,SAAUC,GAIzC,OAHK9E,KAAeA,GAAgBzB,QAAQ,mBAAmByB,eAC/DO,KAAK4B,eAAeF,QAAU,IAAIjC,GAAc8E,GAChDvE,KAAK4B,eAAeD,SAAW4C,EACxBvE,MAwBT,SAASwE,GAAcC,EAAGjC,GACxB,OAAIiC,GAAK,GAAsB,IAAjBjC,EAAM5D,QAAgB4D,EAAM1B,MAAc,EACpD0B,EAAMvC,WAAmB,EACzBwE,GAAMA,EAEJjC,EAAM3B,SAAW2B,EAAM5D,OAAe4D,EAAM9B,OAAOgE,KAAKC,KAAK/F,OAAmB4D,EAAM5D,QAGxF6F,EAAIjC,EAAMpC,gBAAeoC,EAAMpC,cA3BrC,SAAiCqE,GAc/B,OAbIA,GAFQ,QAGVA,EAHU,SAOVA,IACAA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,GACXA,KAEKA,EAa4CG,CAAwBH,IACvEA,GAAKjC,EAAM5D,OAAe6F,EAEzBjC,EAAM1B,MAIJ0B,EAAM5D,QAHX4D,EAAMtB,cAAe,EACd,IA4HX,SAASyB,GAAa7C,GACpB,IAAI0C,EAAQ1C,EAAO8B,eACnBY,EAAMtB,cAAe,EAChBsB,EAAMrB,kBACT5B,GAAM,eAAgBiD,EAAM3B,SAC5B2B,EAAMrB,iBAAkB,EACpBqB,EAAMvB,KAAMlD,EAAI8G,SAASC,GAAehF,GAAagF,GAAchF,IAI3E,SAASgF,GAAchF,GACrBP,GAAM,iBACNO,EAAOoD,KAAK,YACZ6B,GAAKjF,GASP,SAAS4D,GAAc5D,EAAQ0C,GACxBA,EAAMf,cACTe,EAAMf,aAAc,EACpB1D,EAAI8G,SAASG,GAAgBlF,EAAQ0C,IAIzC,SAASwC,GAAelF,EAAQ0C,GAE9B,IADA,IAAIyC,EAAMzC,EAAM5D,QACR4D,EAAMxB,UAAYwB,EAAM3B,UAAY2B,EAAM1B,OAAS0B,EAAM5D,OAAS4D,EAAMpC,gBAC9Eb,GAAM,wBACNO,EAAOgC,KAAK,GACRmD,IAAQzC,EAAM5D,SAELqG,EAAMzC,EAAM5D,OAE3B4D,EAAMf,aAAc,EAyOtB,SAASyD,GAAiBC,GACxB5F,GAAM,4BACN4F,EAAKrD,KAAK,GAsBZ,SAASsD,GAAQtF,EAAQ0C,GAClBA,EAAMxB,UACTzB,GAAM,iBACNO,EAAOgC,KAAK,IAGdU,EAAMnB,iBAAkB,EACxBmB,EAAMhB,WAAa,EACnB1B,EAAOoD,KAAK,UACZ6B,GAAKjF,GACD0C,EAAM3B,UAAY2B,EAAMxB,SAASlB,EAAOgC,KAAK,GAanD,SAASiD,GAAKjF,GACZ,IAAI0C,EAAQ1C,EAAO8B,eAEnB,IADArC,GAAM,OAAQiD,EAAM3B,SACb2B,EAAM3B,SAA6B,OAAlBf,EAAOgC,UAmFjC,SAASuD,GAASZ,EAAGjC,GAEnB,OAAqB,IAAjBA,EAAM5D,OAAqB,MAG3B4D,EAAMvC,WAAYqF,EAAM9C,EAAM9B,OAAO6E,SAAkBd,GAAKA,GAAKjC,EAAM5D,QAEtD0G,EAAf9C,EAAMd,QAAec,EAAM9B,OAAO8E,KAAK,IAAqC,IAAxBhD,EAAM9B,OAAO9B,OAAoB4D,EAAM9B,OAAOgE,KAAKC,KAAgBnC,EAAM9B,OAAO+E,OAAOjD,EAAM5D,QACrJ4D,EAAM9B,OAAOgF,SAGbJ,EASJ,SAAyBb,EAAGkB,EAAMC,GAChC,IAAIN,EACAb,EAAIkB,EAAKjB,KAAKC,KAAK/F,QAErB0G,EAAMK,EAAKjB,KAAKC,KAAKkB,MAAM,EAAGpB,GAC9BkB,EAAKjB,KAAKC,KAAOgB,EAAKjB,KAAKC,KAAKkB,MAAMpB,IAGtCa,EAFSb,IAAMkB,EAAKjB,KAAKC,KAAK/F,OAExB+G,EAAKJ,QAGLK,EASV,SAA8BnB,EAAGkB,GAC/B,IAAIG,EAAIH,EAAKjB,KACTqB,EAAI,EACJT,EAAMQ,EAAEnB,KACZF,GAAKa,EAAI1G,OACT,KAAOkH,EAAIA,EAAEE,MAAM,CACjB,IAAIC,EAAMH,EAAEnB,KACRuB,EAAKzB,EAAIwB,EAAIrH,OAASqH,EAAIrH,OAAS6F,EAGvC,GAFIyB,IAAOD,EAAIrH,OAAQ0G,GAAOW,EAASX,GAAOW,EAAIJ,MAAM,EAAGpB,GAEjD,KADVA,GAAKyB,GACQ,CACPA,IAAOD,EAAIrH,UACXmH,EACED,EAAEE,KAAML,EAAKjB,KAAOoB,EAAEE,KAAUL,EAAKjB,KAAOiB,EAAKQ,KAAO,OAE5DR,EAAKjB,KAAOoB,EACZA,EAAEnB,KAAOsB,EAAIJ,MAAMK,IAErB,QAEAH,EAGJ,OADAJ,EAAK/G,QAAUmH,EACRT,EAhCcc,CAAqB3B,EAAGkB,GAsC/C,SAAwBlB,EAAGkB,GACzB,IAAIL,EAAMxG,EAAOuH,YAAY5B,GACzBqB,EAAIH,EAAKjB,KACTqB,EAAI,EACRD,EAAEnB,KAAK2B,KAAKhB,GACZb,GAAKqB,EAAEnB,KAAK/F,OACZ,KAAOkH,EAAIA,EAAEE,MAAM,CACjB,IAAIO,EAAMT,EAAEnB,KACRuB,EAAKzB,EAAI8B,EAAI3H,OAAS2H,EAAI3H,OAAS6F,EAGvC,GAFA8B,EAAID,KAAKhB,EAAKA,EAAI1G,OAAS6F,EAAG,EAAGyB,GAEvB,KADVzB,GAAKyB,GACQ,CACPA,IAAOK,EAAI3H,UACXmH,EACED,EAAEE,KAAML,EAAKjB,KAAOoB,EAAEE,KAAUL,EAAKjB,KAAOiB,EAAKQ,KAAO,OAE5DR,EAAKjB,KAAOoB,EACZA,EAAEnB,KAAO4B,EAAIV,MAAMK,IAErB,QAEAH,EAGJ,OADAJ,EAAK/G,QAAUmH,EACRT,EA9D8CkB,CAAe/B,EAAGkB,GAEvE,OAAOL,EAtBCmB,CAAgBhC,EAAGjC,EAAM9B,OAAQ8B,EAAMd,SAGxC4D,GAVP,IAAIA,EA4FN,SAASoB,GAAY5G,GACnB,IAAI0C,EAAQ1C,EAAO8B,eAInB,GAAIY,EAAM5D,OAAS,EAAG,MAAM,IAAI2E,MAAM,8CAEjCf,EAAMzB,aACTyB,EAAM1B,OAAQ,EACd/C,EAAI8G,SAAS8B,GAAenE,EAAO1C,IAIvC,SAAS6G,GAAcnE,EAAO1C,GAEvB0C,EAAMzB,YAA+B,IAAjByB,EAAM5D,SAC7B4D,EAAMzB,YAAa,EACnBjB,EAAO+B,UAAW,EAClB/B,EAAOoD,KAAK,QAIhB,SAAS0D,GAAQC,EAAIC,GACnB,IAAK,IAAIC,EAAI,EAAGC,EAAIH,EAAGjI,OAAQmI,EAAIC,EAAGD,IACpC,GAAIF,EAAGE,KAAOD,EAAG,OAAOC,EAE1B,OAAQ,EApoBV5I,GAASiF,UAAUtB,KAAO,SAAU2C,GAClClF,GAAM,OAAQkF,GACdA,EAAIwC,SAASxC,EAAG,IAChB,IAAIjC,EAAQxC,KAAK4B,eACbsF,EAAQzC,EAOZ,GALU,IAANA,IAASjC,EAAMrB,iBAAkB,GAK3B,IAANsD,GAAWjC,EAAMtB,eAAiBsB,EAAM5D,QAAU4D,EAAMpC,eAAiBoC,EAAM1B,OAGjF,OAFAvB,GAAM,qBAAsBiD,EAAM5D,OAAQ4D,EAAM1B,OAC3B,IAAjB0B,EAAM5D,QAAgB4D,EAAM1B,MAAO4F,GAAY1G,MAAW2C,GAAa3C,MACpE,KAMT,GAAU,KAHVyE,EAAID,GAAcC,EAAGjC,KAGNA,EAAM1B,MAEnB,OADqB,IAAjB0B,EAAM5D,QAAc8H,GAAY1G,MAC7B,KA0BT,IA4BIsF,EA5BA6B,EAAS3E,EAAMtB,aAiDnB,OAhDA3B,GAAM,gBAAiB4H,IAGF,IAAjB3E,EAAM5D,QAAgB4D,EAAM5D,OAAS6F,EAAIjC,EAAMpC,gBAEjDb,GAAM,6BADN4H,GAAS,GAMP3E,EAAM1B,OAAS0B,EAAMxB,QAEvBzB,GAAM,mBADN4H,GAAS,GAEAA,IACT5H,GAAM,WACNiD,EAAMxB,SAAU,EAChBwB,EAAMvB,MAAO,EAEQ,IAAjBuB,EAAM5D,SAAc4D,EAAMtB,cAAe,GAE7ClB,KAAK+B,MAAMS,EAAMpC,eACjBoC,EAAMvB,MAAO,EAGRuB,EAAMxB,UAASyD,EAAID,GAAc0C,EAAO1E,KAMnC,QAFD8C,EAAPb,EAAI,EAASY,GAASZ,EAAGjC,GAAkB,OAG7CA,EAAMtB,cAAe,EACrBuD,EAAI,GAEJjC,EAAM5D,QAAU6F,EAGG,IAAjBjC,EAAM5D,SAGH4D,EAAM1B,QAAO0B,EAAMtB,cAAe,GAGnCgG,IAAUzC,GAAKjC,EAAM1B,OAAO4F,GAAY1G,OAGlC,OAARsF,GAActF,KAAKkD,KAAK,OAAQoC,GAE7BA,GAkETnH,GAASiF,UAAUrB,MAAQ,SAAU0C,GACnCzE,KAAKkD,KAAK,QAAS,IAAIK,MAAM,gCAG/BpF,GAASiF,UAAUgE,KAAO,SAAUC,EAAMC,GACxC,IAAIC,EAAMvH,KACNwC,EAAQxC,KAAK4B,eAEjB,OAAQY,EAAM5B,YACZ,KAAK,EACH4B,EAAM7B,MAAQ0G,EACd,MACF,KAAK,EACH7E,EAAM7B,MAAQ,CAAC6B,EAAM7B,MAAO0G,GAC5B,MACF,QACE7E,EAAM7B,MAAM+B,KAAK2E,GAGrB7E,EAAM5B,YAAc,EACpBrB,GAAM,wBAAyBiD,EAAM5B,WAAY0G,GAEjD,IAEIE,IAFUF,IAA6B,IAAjBA,EAAS7E,MAAkB4E,IAASI,EAAQC,QAAUL,IAASI,EAAQE,OAE7EC,EAAQC,EAI5B,SAASC,EAASjG,EAAUkG,GAC1BxI,GAAM,YACFsC,IAAa0F,GACXQ,IAAwC,IAA1BA,EAAWC,aAC3BD,EAAWC,YAAa,EAoB5BzI,GAAM,WAEN8H,EAAKY,eAAe,QAASC,GAC7Bb,EAAKY,eAAe,SAAUE,GAC9Bd,EAAKY,eAAe,QAASG,GAC7Bf,EAAKY,eAAe,QAASI,GAC7BhB,EAAKY,eAAe,SAAUH,GAC9BP,EAAIU,eAAe,MAAOL,GAC1BL,EAAIU,eAAe,MAAOJ,GAC1BN,EAAIU,eAAe,OAAQK,GAE3BC,GAAY,GAOR/F,EAAMhB,YAAgB6F,EAAKmB,iBAAkBnB,EAAKmB,eAAeC,WAAYL,KAhCnF,SAASR,IACPrI,GAAM,SACN8H,EAAK5E,MAfHD,EAAMzB,WAAYhD,EAAI8G,SAAS2C,GAAYD,EAAImB,KAAK,MAAOlB,GAE/DH,EAAKsB,GAAG,SAAUb,GAoBlB,IAAIM,EA4FN,SAAqBb,GACnB,OAAO,WACL,IAAI/E,EAAQ+E,EAAI3F,eAChBrC,GAAM,cAAeiD,EAAMhB,YACvBgB,EAAMhB,YAAYgB,EAAMhB,aACH,IAArBgB,EAAMhB,YAAoBhD,EAAgB+I,EAAK,UACjD/E,EAAM3B,SAAU,EAChBkE,GAAKwC,KAnGKqB,CAAYrB,GAC1BF,EAAKsB,GAAG,QAASP,GAEjB,IAAIG,GAAY,EA2BhB,IAAIM,GAAsB,EAE1B,SAASP,EAAOlG,GACd7C,GAAM,UACNsJ,GAAsB,GAElB,IADMxB,EAAK5D,MAAMrB,IACCyG,KAKM,IAArBrG,EAAM5B,YAAoB4B,EAAM7B,QAAU0G,GAAQ7E,EAAM5B,WAAa,IAAqC,IAAhCgG,GAAQpE,EAAM7B,MAAO0G,MAAkBkB,IACpHhJ,GAAM,8BAA+BgI,EAAI3F,eAAeJ,YACxD+F,EAAI3F,eAAeJ,aACnBqH,GAAsB,GAExBtB,EAAIuB,SAMR,SAAST,EAAQ9F,GACfhD,GAAM,UAAWgD,GACjBsF,IACAR,EAAKY,eAAe,QAASI,GACU,IAAnC7J,EAAgB6I,EAAM,UAAgBA,EAAKnE,KAAK,QAASX,GAO/D,SAAS2F,IACPb,EAAKY,eAAe,SAAUE,GAC9BN,IAGF,SAASM,IACP5I,GAAM,YACN8H,EAAKY,eAAe,QAASC,GAC7BL,IAIF,SAASA,IACPtI,GAAM,UACNgI,EAAIM,OAAOR,GAYb,OA1DAE,EAAIoB,GAAG,OAAQL,GA9gBjB,SAAyB7J,EAASsK,EAAOC,GAGvC,GAAuC,mBAA5BvK,EAAQwK,gBAAgC,OAAOxK,EAAQwK,gBAAgBF,EAAOC,GAMpFvK,EAAQyK,SAAYzK,EAAQyK,QAAQH,GAAuC1K,EAAQI,EAAQyK,QAAQH,IAAStK,EAAQyK,QAAQH,GAAOnF,QAAQoF,GAASvK,EAAQyK,QAAQH,GAAS,CAACC,EAAIvK,EAAQyK,QAAQH,IAAtJtK,EAAQkK,GAAGI,EAAOC,GAkiBnEC,CAAgB5B,EAAM,QAASgB,GAO/BhB,EAAKqB,KAAK,QAASR,GAMnBb,EAAKqB,KAAK,SAAUP,GAQpBd,EAAKnE,KAAK,OAAQqE,GAGb/E,EAAM3B,UACTtB,GAAM,eACNgI,EAAI4B,UAGC9B,GAeTlJ,GAASiF,UAAUyE,OAAS,SAAUR,GACpC,IAAI7E,EAAQxC,KAAK4B,eACbmG,EAAa,CAAEC,YAAY,GAG/B,GAAyB,IAArBxF,EAAM5B,WAAkB,OAAOZ,KAGnC,GAAyB,IAArBwC,EAAM5B,WAER,OAAIyG,GAAQA,IAAS7E,EAAM7B,QAEtB0G,IAAMA,EAAO7E,EAAM7B,OAGxB6B,EAAM7B,MAAQ,KACd6B,EAAM5B,WAAa,EACnB4B,EAAM3B,SAAU,EACZwG,GAAMA,EAAKnE,KAAK,SAAUlD,KAAM+H,IARK/H,KAc3C,IAAKqH,EAAM,CAET,IAAI+B,EAAQ5G,EAAM7B,MACdsE,EAAMzC,EAAM5B,WAChB4B,EAAM7B,MAAQ,KACd6B,EAAM5B,WAAa,EACnB4B,EAAM3B,SAAU,EAEhB,IAAK,IAAIkG,EAAI,EAAGA,EAAI9B,EAAK8B,IACvBqC,EAAMrC,GAAG7D,KAAK,SAAUlD,KAAM+H,GAC/B,OAAO/H,KAIV,IAAIqJ,EAAQzC,GAAQpE,EAAM7B,MAAO0G,GACjC,OAAe,IAAXgC,IAEJ7G,EAAM7B,MAAM2I,OAAOD,EAAO,GAC1B7G,EAAM5B,YAAc,EACK,IAArB4B,EAAM5B,aAAkB4B,EAAM7B,MAAQ6B,EAAM7B,MAAM,IAEtD0G,EAAKnE,KAAK,SAAUlD,KAAM+H,IAND/H,MAa3B7B,GAASiF,UAAUuF,GAAK,SAAUY,EAAIP,GACpC,IAAIQ,EAAM3K,EAAOuE,UAAUuF,GAAGzG,KAAKlC,KAAMuJ,EAAIP,GAE7C,GAAW,SAAPO,GAEkC,IAAhCvJ,KAAK4B,eAAef,SAAmBb,KAAKmJ,cAC3C,GAAW,aAAPI,EAAmB,CAC5B,IAAI/G,EAAQxC,KAAK4B,eACZY,EAAMzB,YAAeyB,EAAMpB,oBAC9BoB,EAAMpB,kBAAoBoB,EAAMtB,cAAe,EAC/CsB,EAAMrB,iBAAkB,EACnBqB,EAAMxB,QAEAwB,EAAM5D,QACf+D,GAAa3C,MAFbjC,EAAI8G,SAASK,GAAkBlF,OAOrC,OAAOwJ,GAETrL,GAASiF,UAAUqG,YAActL,GAASiF,UAAUuF,GASpDxK,GAASiF,UAAU+F,OAAS,WAC1B,IAAI3G,EAAQxC,KAAK4B,eAMjB,OALKY,EAAM3B,UACTtB,GAAM,UACNiD,EAAM3B,SAAU,EAMpB,SAAgBf,EAAQ0C,GACjBA,EAAMnB,kBACTmB,EAAMnB,iBAAkB,EACxBtD,EAAI8G,SAASO,GAAStF,EAAQ0C,IAR9B2G,CAAOnJ,KAAMwC,IAERxC,MAuBT7B,GAASiF,UAAU0F,MAAQ,WAOzB,OANAvJ,GAAM,wBAAyBS,KAAK4B,eAAef,UAC/C,IAAUb,KAAK4B,eAAef,UAChCtB,GAAM,SACNS,KAAK4B,eAAef,SAAU,EAC9Bb,KAAKkD,KAAK,UAELlD,MAYT7B,GAASiF,UAAUsG,KAAO,SAAU5J,GAClC,IAAI6J,EAAQ3J,KAERwC,EAAQxC,KAAK4B,eACbgI,GAAS,EA4Bb,IAAK,IAAI7C,KA1BTjH,EAAO6I,GAAG,OAAO,WAEf,GADApJ,GAAM,eACFiD,EAAMd,UAAYc,EAAM1B,MAAO,CACjC,IAAIsB,EAAQI,EAAMd,QAAQe,MACtBL,GAASA,EAAMxD,QAAQ+K,EAAMjH,KAAKN,GAGxCuH,EAAMjH,KAAK,SAGb5C,EAAO6I,GAAG,QAAQ,SAAUvG,IAC1B7C,GAAM,gBACFiD,EAAMd,UAASU,EAAQI,EAAMd,QAAQ+B,MAAMrB,IAG3CI,EAAMvC,YAAe,MAAAmC,KAAyDI,EAAMvC,YAAgBmC,GAAUA,EAAMxD,UAE9G+K,EAAMjH,KAAKN,KAEnBwH,GAAS,EACT9J,EAAOgJ,aAMGhJ,OACIiD,IAAZ/C,KAAK+G,IAAyC,mBAAdjH,EAAOiH,KACzC/G,KAAK+G,GAAK,SAAU8C,GAClB,OAAO,WACL,OAAO/J,EAAO+J,GAAQC,MAAMhK,EAAQiK,YAF9B,CAIRhD,IAKN,IAAK,IAAItC,EAAI,EAAGA,EAAI7E,GAAahB,OAAQ6F,IACvC3E,EAAO6I,GAAG/I,GAAa6E,GAAIzE,KAAKkD,KAAK8G,KAAKhK,KAAMJ,GAAa6E,KAa/D,OARAzE,KAAK+B,MAAQ,SAAU0C,GACrBlF,GAAM,gBAAiBkF,GACnBmF,IACFA,GAAS,EACT9J,EAAOqJ,WAIJnJ,MAGTb,OAAO0E,eAAe1F,GAASiF,UAAW,wBAAyB,CAIjE6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAK4B,eAAexB,iBAK/BjC,GAAS+L,UAAY7E,6CC51BjBtH,GAAMC,QAAQ,wBAelB,SAASmM,GAAc3H,GACrB,IAAImH,EAAQ3J,KAEZA,KAAKgG,KAAO,KACZhG,KAAKoK,MAAQ,KACbpK,KAAKqK,OAAS,YAolBhB,SAAwBC,EAAS9H,EAAO2B,GACtC,IAAIiG,EAAQE,EAAQF,MACpBE,EAAQF,MAAQ,KAChB,KAAOA,GAAO,CACZ,IAAIhG,EAAKgG,EAAMG,SACf/H,EAAMgI,YACNpG,EAAGD,GACHiG,EAAQA,EAAMpE,KAEZxD,EAAMiI,mBACRjI,EAAMiI,mBAAmBzE,KAAOsE,EAEhC9H,EAAMiI,mBAAqBH,EA/lB3BI,CAAef,EAAOnH,IAlB1BvE,OAAOC,QAAUyM,GAwBjB,IAIIvM,GAJAwM,IAAcnD,EAAQoD,SAAW,CAAC,QAAS,SAASjE,QAAQa,EAAQqD,QAAQjF,MAAM,EAAG,KAAO,EAAIkF,aAAehN,GAAI8G,SAOvH8F,GAASK,cAAgBA,GAGzB,IAAI9L,GAAOC,OAAOC,OAAOpB,QAAQ,iBACjCkB,GAAKG,SAAWrB,QAAQ,YAIxB,IAAIiN,GAAe,CACjBC,UAAWlN,QAAQ,mBAKjBa,GAASb,QAAQ,6BAKjBc,GAASd,QAAQ,eAAec,OAChCC,GAAgBC,EAAOC,YAAc,aAUzC,IA2IIkM,GA3IAxL,GAAc3B,QAAQ,8BAI1B,SAASoN,MAET,SAASJ,GAAcnL,EAASC,GAC9B1B,GAASA,IAAUJ,QAAQ,oBAE3B6B,EAAUA,GAAW,GAOrB,IAAIE,EAAWD,aAAkB1B,GAIjC4B,KAAKC,aAAeJ,EAAQI,WAExBF,IAAUC,KAAKC,WAAaD,KAAKC,cAAgBJ,EAAQwL,oBAK7D,IAAIlL,EAAMN,EAAQO,cACdkL,EAAczL,EAAQ0L,sBACtBhL,EAAaP,KAAKC,WAAa,GAAK,MAElBD,KAAKI,cAAvBD,GAAe,IAARA,EAAgCA,EAAaJ,IAAauL,GAA+B,IAAhBA,GAAyCA,EAAsC/K,EAGnKP,KAAKI,cAAgBI,KAAKC,MAAMT,KAAKI,eAGrCJ,KAAKwL,aAAc,EAGnBxL,KAAKyI,WAAY,EAEjBzI,KAAKyL,QAAS,EAEdzL,KAAKc,OAAQ,EAEbd,KAAK0L,UAAW,EAGhB1L,KAAKsB,WAAY,EAKjB,IAAIqK,GAAqC,IAA1B9L,EAAQ+L,cACvB5L,KAAK4L,eAAiBD,EAKtB3L,KAAKuB,gBAAkB1B,EAAQ0B,iBAAmB,OAKlDvB,KAAKpB,OAAS,EAGdoB,KAAK6L,SAAU,EAGf7L,KAAK8L,OAAS,EAMd9L,KAAKiB,MAAO,EAKZjB,KAAK+L,kBAAmB,EAGxB/L,KAAKgM,QAAU,SAAUzJ,IA4R3B,SAAiBzC,EAAQyC,GACvB,IAAIC,EAAQ1C,EAAO0I,eACfvH,EAAOuB,EAAMvB,KACbmD,EAAK5B,EAAMyJ,QAIf,GAdF,SAA4BzJ,GAC1BA,EAAMqJ,SAAU,EAChBrJ,EAAMyJ,QAAU,KAChBzJ,EAAM5D,QAAU4D,EAAM0J,SACtB1J,EAAM0J,SAAW,EAQjBC,CAAmB3J,GAEfD,GAtCN,SAAsBzC,EAAQ0C,EAAOvB,EAAMsB,EAAI6B,KAC3C5B,EAAMgI,UAEJvJ,GAGFlD,GAAI8G,SAAST,EAAI7B,GAGjBxE,GAAI8G,SAASuH,GAAatM,EAAQ0C,GAClC1C,EAAO0I,eAAe6D,cAAe,EACrCvM,EAAOoD,KAAK,QAASX,KAIrB6B,EAAG7B,GACHzC,EAAO0I,eAAe6D,cAAe,EACrCvM,EAAOoD,KAAK,QAASX,GAGrB6J,GAAYtM,EAAQ0C,IAkBd8J,CAAaxM,EAAQ0C,EAAOvB,EAAMsB,EAAI6B,OAAS,CAErD,IAAIsH,EAAWa,GAAW/J,GAErBkJ,GAAalJ,EAAMsJ,QAAWtJ,EAAMuJ,mBAAoBvJ,EAAMgK,iBACjEC,GAAY3M,EAAQ0C,GAGlBvB,EAEF2J,GAAW8B,GAAY5M,EAAQ0C,EAAOkJ,EAAUtH,GAGhDsI,GAAW5M,EAAQ0C,EAAOkJ,EAAUtH,IA/StC4H,CAAQlM,EAAQyC,IAIlBvC,KAAKiM,QAAU,KAGfjM,KAAKkM,SAAW,EAEhBlM,KAAKwM,gBAAkB,KACvBxM,KAAK2M,oBAAsB,KAI3B3M,KAAKwK,UAAY,EAIjBxK,KAAK4M,aAAc,EAGnB5M,KAAKqM,cAAe,EAGpBrM,KAAK6M,qBAAuB,EAI5B7M,KAAKyK,mBAAqB,IAAIN,GAAcnK,MA0C9C,SAAS2K,GAAS9K,GAUhB,GATAzB,GAASA,IAAUJ,QAAQ,sBAStBmN,GAAgBjJ,KAAKyI,GAAU3K,OAAWA,gBAAgB5B,IAC7D,OAAO,IAAIuM,GAAS9K,GAGtBG,KAAKwI,eAAiB,IAAIwC,GAAcnL,EAASG,MAGjDA,KAAK8M,UAAW,EAEZjN,IAC2B,mBAAlBA,EAAQ4D,QAAsBzD,KAAK+M,OAASlN,EAAQ4D,OAEjC,mBAAnB5D,EAAQmN,SAAuBhN,KAAKiN,QAAUpN,EAAQmN,QAElC,mBAApBnN,EAAQmC,UAAwBhC,KAAKiC,SAAWpC,EAAQmC,SAEtC,mBAAlBnC,EAAQqN,QAAsBlN,KAAKmN,OAAStN,EAAQqN,QAGjErO,GAAOqD,KAAKlC,MAgJd,SAASoN,GAAQtN,EAAQ0C,EAAOwK,EAAQ/H,EAAK7C,EAAOT,EAAUyC,GAC5D5B,EAAM0J,SAAWjH,EACjBzC,EAAMyJ,QAAU7H,EAChB5B,EAAMqJ,SAAU,EAChBrJ,EAAMvB,MAAO,EACT+L,EAAQlN,EAAOmN,QAAQ7K,EAAOI,EAAMwJ,SAAclM,EAAOiN,OAAO3K,EAAOT,EAAUa,EAAMwJ,SAC3FxJ,EAAMvB,MAAO,EA2Df,SAASyL,GAAW5M,EAAQ0C,EAAOkJ,EAAUtH,GACtCsH,GASP,SAAsB5L,EAAQ0C,GACP,IAAjBA,EAAM5D,QAAgB4D,EAAMiG,YAC9BjG,EAAMiG,WAAY,EAClB3I,EAAOoD,KAAK,UAZCmK,CAAavN,EAAQ0C,GACpCA,EAAMgI,YACNpG,IACAgI,GAAYtM,EAAQ0C,GActB,SAASiK,GAAY3M,EAAQ0C,GAC3BA,EAAMuJ,kBAAmB,EACzB,IAAI3B,EAAQ5H,EAAMgK,gBAElB,GAAI1M,EAAOmN,SAAW7C,GAASA,EAAMpE,KAAM,CAEzC,IAAIgB,EAAIxE,EAAMqK,qBACVnM,EAAS,IAAI4M,MAAMtG,GACnBuG,EAAS/K,EAAMiI,mBACnB8C,EAAOnD,MAAQA,EAIf,IAFA,IAAIoD,EAAQ,EACRC,GAAa,EACVrD,GACL1J,EAAO8M,GAASpD,EACXA,EAAMsD,QAAOD,GAAa,GAC/BrD,EAAQA,EAAMpE,KACdwH,GAAS,EAEX9M,EAAO+M,WAAaA,EAEpBL,GAAQtN,EAAQ0C,GAAO,EAAMA,EAAM5D,OAAQ8B,EAAQ,GAAI6M,EAAOlD,QAI9D7H,EAAMgI,YACNhI,EAAMmK,oBAAsB,KACxBY,EAAOvH,MACTxD,EAAMiI,mBAAqB8C,EAAOvH,KAClCuH,EAAOvH,KAAO,MAEdxD,EAAMiI,mBAAqB,IAAIN,GAAc3H,GAE/CA,EAAMqK,qBAAuB,MACxB,CAEL,KAAOzC,GAAO,CACZ,IAAIhI,EAAQgI,EAAMhI,MACdT,EAAWyI,EAAMzI,SACjByC,EAAKgG,EAAMG,SAUf,GAPA6C,GAAQtN,EAAQ0C,GAAO,EAFbA,EAAMvC,WAAa,EAAImC,EAAMxD,OAEJwD,EAAOT,EAAUyC,GACpDgG,EAAQA,EAAMpE,KACdxD,EAAMqK,uBAKFrK,EAAMqJ,QACR,MAIU,OAAVzB,IAAgB5H,EAAMmK,oBAAsB,MAGlDnK,EAAMgK,gBAAkBpC,EACxB5H,EAAMuJ,kBAAmB,EAiC3B,SAASQ,GAAW/J,GAClB,OAAOA,EAAMiJ,QAA2B,IAAjBjJ,EAAM5D,QAA0C,OAA1B4D,EAAMgK,kBAA6BhK,EAAMkJ,WAAalJ,EAAMqJ,QAE3G,SAAS8B,GAAU7N,EAAQ0C,GACzB1C,EAAOqN,QAAO,SAAUhJ,GACtB3B,EAAMgI,YACFrG,GACFrE,EAAOoD,KAAK,QAASiB,GAEvB3B,EAAMoK,aAAc,EACpB9M,EAAOoD,KAAK,aACZkJ,GAAYtM,EAAQ0C,MAgBxB,SAAS4J,GAAYtM,EAAQ0C,GAC3B,IAAIoL,EAAOrB,GAAW/J,GAQtB,OAPIoL,KAfN,SAAmB9N,EAAQ0C,GACpBA,EAAMoK,aAAgBpK,EAAMgJ,cACF,mBAAlB1L,EAAOqN,QAChB3K,EAAMgI,YACNhI,EAAMgJ,aAAc,EACpBzN,GAAI8G,SAAS8I,GAAW7N,EAAQ0C,KAEhCA,EAAMoK,aAAc,EACpB9M,EAAOoD,KAAK,eAQd2K,CAAU/N,EAAQ0C,GACM,IAApBA,EAAMgI,YACRhI,EAAMkJ,UAAW,EACjB5L,EAAOoD,KAAK,YAGT0K,EAzhBT1O,GAAKG,SAASsL,GAAU9L,IAmHxBmM,GAAc5H,UAAU0K,UAAY,WAGlC,IAFA,IAAIC,EAAU/N,KAAKwM,gBACfwB,EAAM,GACHD,GACLC,EAAItL,KAAKqL,GACTA,EAAUA,EAAQ/H,KAEpB,OAAOgI,GAGT,WACE,IACE7O,OAAO0E,eAAemH,GAAc5H,UAAW,SAAU,CACvDU,IAAKmH,GAAaC,WAAU,WAC1B,OAAOlL,KAAK8N,cACX,6EAAmF,aAExF,MAAOG,KAPX,GAasB,mBAAXC,QAAyBA,OAAOC,aAAiE,mBAA3CC,SAAShL,UAAU8K,OAAOC,cACzFhD,GAAkBiD,SAAShL,UAAU8K,OAAOC,aAC5ChP,OAAO0E,eAAe8G,GAAUuD,OAAOC,YAAa,CAClDnK,MAAO,SAAUqK,GACf,QAAIlD,GAAgBjJ,KAAKlC,KAAMqO,IAC3BrO,OAAS2K,KAEN0D,GAAUA,EAAO7F,0BAA0BwC,QAItDG,GAAkB,SAAUkD,GAC1B,OAAOA,aAAkBrO,MAqC7B2K,GAASvH,UAAUgE,KAAO,WACxBpH,KAAKkD,KAAK,QAAS,IAAIK,MAAM,+BA8B/BoH,GAASvH,UAAUK,MAAQ,SAAUrB,EAAOT,EAAUyC,GACpD,IAnOqBvB,EAmOjBL,EAAQxC,KAAKwI,eACblD,GAAM,EACNoI,GAASlL,EAAMvC,aArOE4C,EAqO0BT,EApOxCtD,GAAOgE,SAASD,IAAQA,aAAe9D,IAwP9C,OAlBI2O,IAAU5O,GAAOgE,SAASV,KAC5BA,EA3OJ,SAA6BA,GAC3B,OAAOtD,GAAOuE,KAAKjB,GA0OTkB,CAAoBlB,IAGN,mBAAbT,IACTyC,EAAKzC,EACLA,EAAW,MAGT+L,EAAO/L,EAAW,SAAmBA,IAAUA,EAAWa,EAAMjB,iBAElD,mBAAP6C,IAAmBA,EAAKgH,IAE/B5I,EAAM1B,MA7CZ,SAAuBhB,EAAQsE,GAC7B,IAAI7B,EAAK,IAAIgB,MAAM,mBAEnBzD,EAAOoD,KAAK,QAASX,GACrBxE,GAAI8G,SAAST,EAAI7B,GAyCA+L,CAActO,KAAMoE,IAAasJ,GAnCpD,SAAoB5N,EAAQ0C,EAAOJ,EAAOgC,GACxC,IAAImK,GAAQ,EACRhM,GAAK,EAYT,OAVc,OAAVH,EACFG,EAAK,IAAIS,UAAU,uCACO,iBAAVZ,QAAgCW,IAAVX,GAAwBI,EAAMvC,aACpEsC,EAAK,IAAIS,UAAU,oCAEjBT,IACFzC,EAAOoD,KAAK,QAASX,GACrBxE,GAAI8G,SAAST,EAAI7B,GACjBgM,GAAQ,GAEHA,EAqBoDC,CAAWxO,KAAMwC,EAAOJ,EAAOgC,MACxF5B,EAAMgI,YACNlF,EAkDJ,SAAuBxF,EAAQ0C,EAAOkL,EAAOtL,EAAOT,EAAUyC,GAC5D,IAAKsJ,EAAO,CACV,IAAIe,EAtBR,SAAqBjM,EAAOJ,EAAOT,GAC5Ba,EAAMvC,aAAsC,IAAxBuC,EAAMoJ,eAA4C,iBAAVxJ,IAC/DA,EAAQtD,GAAOuE,KAAKjB,EAAOT,IAE7B,OAAOS,EAkBUsM,CAAYlM,EAAOJ,EAAOT,GACrCS,IAAUqM,IACZf,GAAQ,EACR/L,EAAW,SACXS,EAAQqM,GAGZ,IAAIxJ,EAAMzC,EAAMvC,WAAa,EAAImC,EAAMxD,OAEvC4D,EAAM5D,QAAUqG,EAEhB,IAAIK,EAAM9C,EAAM5D,OAAS4D,EAAMpC,cAE1BkF,IAAK9C,EAAMiG,WAAY,GAE5B,GAAIjG,EAAMqJ,SAAWrJ,EAAMsJ,OAAQ,CACjC,IAAI6C,EAAOnM,EAAMmK,oBACjBnK,EAAMmK,oBAAsB,CAC1BvK,MAAOA,EACPT,SAAUA,EACV+L,MAAOA,EACPnD,SAAUnG,EACV4B,KAAM,MAEJ2I,EACFA,EAAK3I,KAAOxD,EAAMmK,oBAElBnK,EAAMgK,gBAAkBhK,EAAMmK,oBAEhCnK,EAAMqK,sBAAwB,OAE9BO,GAAQtN,EAAQ0C,GAAO,EAAOyC,EAAK7C,EAAOT,EAAUyC,GAGtD,OAAOkB,EAtFCsJ,CAAc5O,KAAMwC,EAAOkL,EAAOtL,EAAOT,EAAUyC,IAGpDkB,GAGTqF,GAASvH,UAAUyL,KAAO,WACZ7O,KAAKwI,eAEXsD,UAGRnB,GAASvH,UAAU0L,OAAS,WAC1B,IAAItM,EAAQxC,KAAKwI,eAEbhG,EAAMsJ,SACRtJ,EAAMsJ,SAEDtJ,EAAMqJ,SAAYrJ,EAAMsJ,QAAWtJ,EAAMkJ,UAAalJ,EAAMuJ,mBAAoBvJ,EAAMgK,iBAAiBC,GAAYzM,KAAMwC,KAIlImI,GAASvH,UAAU2L,mBAAqB,SAA4BpN,GAGlE,GADwB,iBAAbA,IAAuBA,EAAWA,EAASqN,iBAChD,CAAC,MAAO,OAAQ,QAAS,QAAS,SAAU,SAAU,OAAQ,QAAS,UAAW,WAAY,OAAOpI,SAASjF,EAAW,IAAIqN,gBAAkB,GAAI,MAAM,IAAIhM,UAAU,qBAAuBrB,GAEpM,OADA3B,KAAKwI,eAAejH,gBAAkBI,EAC/B3B,MAUTb,OAAO0E,eAAe8G,GAASvH,UAAW,wBAAyB,CAIjE6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAKwI,eAAepI,iBA8L/BuK,GAASvH,UAAU2J,OAAS,SAAU3K,EAAOT,EAAUyC,GACrDA,EAAG,IAAIb,MAAM,iCAGfoH,GAASvH,UAAU6J,QAAU,KAE7BtC,GAASvH,UAAUX,IAAM,SAAUL,EAAOT,EAAUyC,GAClD,IAAI5B,EAAQxC,KAAKwI,eAEI,mBAAVpG,GACTgC,EAAKhC,EACLA,EAAQ,KACRT,EAAW,MACkB,mBAAbA,IAChByC,EAAKzC,EACLA,EAAW,MAGTS,SAAuCpC,KAAKyD,MAAMrB,EAAOT,GAGzDa,EAAMsJ,SACRtJ,EAAMsJ,OAAS,EACf9L,KAAK8O,UAIFtM,EAAMiJ,QAAWjJ,EAAMkJ,UA0C9B,SAAqB5L,EAAQ0C,EAAO4B,GAClC5B,EAAMiJ,QAAS,EACfW,GAAYtM,EAAQ0C,GAChB4B,IACE5B,EAAMkJ,SAAU3N,GAAI8G,SAAST,GAAStE,EAAO4I,KAAK,SAAUtE,IAElE5B,EAAM1B,OAAQ,EACdhB,EAAOgN,UAAW,EAjDoBmC,CAAYjP,KAAMwC,EAAO4B,IAoEjEjF,OAAO0E,eAAe8G,GAASvH,UAAW,YAAa,CACrDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAKwI,gBAGFxI,KAAKwI,eAAelH,WAE7ByC,IAAK,SAAUC,GAGRhE,KAAKwI,iBAMVxI,KAAKwI,eAAelH,UAAY0C,MAIpC2G,GAASvH,UAAUpB,QAAUrC,GAAYqC,QACzC2I,GAASvH,UAAUa,WAAatE,GAAYuE,UAC5CyG,GAASvH,UAAUnB,SAAW,SAAUkC,EAAKC,GAC3CpE,KAAKyC,MACL2B,EAAGD,mDC3qBkB,IAAZsD,IACNA,EAAQqD,SAC0B,IAAnCrD,EAAQqD,QAAQlE,QAAQ,QACW,IAAnCa,EAAQqD,QAAQlE,QAAQ,QAAqD,IAArCa,EAAQqD,QAAQlE,QAAQ,SAClE3I,OAAOC,QAAU,CAAE2G,SAKrB,SAAkBmE,EAAIkG,EAAMC,EAAMC,GAChC,GAAkB,mBAAPpG,EACT,MAAM,IAAIhG,UAAU,0CAEtB,IACIqM,EAAMtI,EADN9B,EAAM8E,UAAUnL,OAEpB,OAAQqG,GACR,KAAK,EACL,KAAK,EACH,OAAOwC,EAAQ5C,SAASmE,GAC1B,KAAK,EACH,OAAOvB,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,MAElB,KAAK,EACH,OAAOzH,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,EAAMC,MAExB,KAAK,EACH,OAAO1H,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,EAAMC,EAAMC,MAE9B,QAGE,IAFAC,EAAO,IAAI/B,MAAMrI,EAAM,GACvB8B,EAAI,EACGA,EAAIsI,EAAKzQ,QACdyQ,EAAKtI,KAAOgD,UAAUhD,GAExB,OAAOU,EAAQ5C,UAAS,WACtBmE,EAAGc,MAAM,KAAMuF,SAhCnBpR,OAAOC,QAAUuJ,y6qBCgGnB,SAAS6H,GAAeC,GACtB,OAAOpQ,OAAOiE,UAAUoM,SAAStN,KAAKqN,GA3EzBrQ,GAAAb,QANf,SAAiBoR,GACf,OAAInC,MAAMjP,QACDiP,MAAMjP,QAAQoR,GAEQ,mBAAxBH,GAAeG,IAOPvQ,GAAAwQ,UAHjB,SAAmBD,GACjB,MAAsB,kBAARA,GAOFvQ,GAAAyQ,OAHd,SAAgBF,GACd,OAAe,OAARA,GAOgBvQ,GAAA0Q,kBAHzB,SAA2BH,GACzB,OAAc,MAAPA,GAOOvQ,GAAA2Q,SAHhB,SAAkBJ,GAChB,MAAsB,iBAARA,GAOAvQ,GAAA4Q,SAHhB,SAAkBL,GAChB,MAAsB,iBAARA,GAOAvQ,GAAA6Q,SAHhB,SAAkBN,GAChB,MAAsB,iBAARA,GAOGvQ,GAAA8Q,YAHnB,SAAqBP,GACnB,YAAe,IAARA,GAOOvQ,GAAA+Q,SAHhB,SAAkBC,GAChB,MAA8B,oBAAvBZ,GAAeY,IAORhR,GAAAiR,SAHhB,SAAkBV,GAChB,MAAsB,iBAARA,GAA4B,OAARA,GAOtBvQ,GAAAkR,OAHd,SAAgBC,GACd,MAA6B,kBAAtBf,GAAee,IAOTnR,GAAAoR,QAHf,SAAiBC,GACf,MAA8B,mBAAtBjB,GAAeiB,IAA2BA,aAAahN,OAO/CrE,GAAAsR,WAHlB,SAAoBf,GAClB,MAAsB,mBAARA,GAYGvQ,GAAAuR,YARnB,SAAqBhB,GACnB,OAAe,OAARA,GACe,kBAARA,GACQ,iBAARA,GACQ,iBAARA,GACQ,iBAARA,QACQ,IAARA,GAIhBvQ,GAAA4D,SAAmB4N,GAAkB5R,OAAOgE,sVCxExC/E,GAAM2S,GAINC,GAAaxR,OAAOyR,MAAQ,SAAU/N,GACxC,IAAI+N,EAAO,GACX,IAAK,IAAIC,KAAOhO,EACd+N,EAAKlO,KAAKmO,GACX,OAAOD,GAIVE,GAAiB1S,GAGbc,GAAOC,OAAOC,OAAO2R,IACzB7R,GAAKG,SAAW2R,GAGhB,IAAI7S,GAAW8S,GACXtG,GAAWuG,GAEfhS,GAAKG,SAASjB,GAAQD,IAKpB,IADA,IAAIyS,GAAOD,GAAWhG,GAASvH,WACtB+N,GAAI,EAAGA,GAAIP,GAAKhS,OAAQuS,KAAK,CACpC,IAAItH,GAAS+G,GAAKO,IACb/S,GAAOgF,UAAUyG,MAASzL,GAAOgF,UAAUyG,IAAUc,GAASvH,UAAUyG,KAIjF,SAASzL,GAAOyB,GACd,KAAMG,gBAAgB5B,IAAS,OAAO,IAAIA,GAAOyB,GAEjD1B,GAAS+D,KAAKlC,KAAMH,GACpB8K,GAASzI,KAAKlC,KAAMH,GAEhBA,IAAgC,IAArBA,EAAQgC,WAAoB7B,KAAK6B,UAAW,GAEvDhC,IAAgC,IAArBA,EAAQiN,WAAoB9M,KAAK8M,UAAW,GAE3D9M,KAAKoR,eAAgB,EACjBvR,IAAqC,IAA1BA,EAAQuR,gBAAyBpR,KAAKoR,eAAgB,GAErEpR,KAAK0I,KAAK,MAAOd,IAcnB,SAASA,KAGH5H,KAAKoR,eAAiBpR,KAAKwI,eAAe1H,OAI9C/C,GAAI8G,SAASwM,GAASrR,MAGxB,SAASqR,GAAQlM,GACfA,EAAK1C,MAtBPtD,OAAO0E,eAAezF,GAAOgF,UAAW,wBAAyB,CAI/D6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAKwI,eAAepI,iBAmB/BjB,OAAO0E,eAAezF,GAAOgF,UAAW,YAAa,CACnDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAK4B,qBAAwDmB,IAAxB/C,KAAKwI,iBAGvCxI,KAAK4B,eAAeN,WAAatB,KAAKwI,eAAelH,YAE9DyC,IAAK,SAAUC,QAGejB,IAAxB/C,KAAK4B,qBAAwDmB,IAAxB/C,KAAKwI,iBAM9CxI,KAAK4B,eAAeN,UAAY0C,EAChChE,KAAKwI,eAAelH,UAAY0C,MAIpC5F,GAAOgF,UAAUnB,SAAW,SAAUkC,EAAKC,GACzCpE,KAAK0C,KAAK,MACV1C,KAAKyC,MAEL1E,GAAI8G,SAAST,EAAID,QChEnBmN,GAAiBC,GAEbnT,GAASsS,GAGTxR,GAAOC,OAAOC,OAAO2R,IAMzB,SAASS,GAAejP,EAAIoC,GAC1B,IAAI8M,EAAKzR,KAAK0R,gBACdD,EAAGE,cAAe,EAElB,IAAIvN,EAAKqN,EAAGxF,QAEZ,IAAK7H,EACH,OAAOpE,KAAKkD,KAAK,QAAS,IAAIK,MAAM,yCAGtCkO,EAAGG,WAAa,KAChBH,EAAGxF,QAAU,KAED,MAARtH,GACF3E,KAAK0C,KAAKiC,GAEZP,EAAG7B,GAEH,IAAIsP,EAAK7R,KAAK4B,eACdiQ,EAAG7Q,SAAU,GACT6Q,EAAG3Q,cAAgB2Q,EAAGjT,OAASiT,EAAGzR,gBACpCJ,KAAK+B,MAAM8P,EAAGzR,eAIlB,SAASmR,GAAU1R,GACjB,KAAMG,gBAAgBuR,IAAY,OAAO,IAAIA,GAAU1R,GAEvDzB,GAAO8D,KAAKlC,KAAMH,GAElBG,KAAK0R,gBAAkB,CACrBF,eAAgBA,GAAexH,KAAKhK,MACpC8R,eAAe,EACfH,cAAc,EACd1F,QAAS,KACT2F,WAAY,KACZG,cAAe,MAIjB/R,KAAK4B,eAAeV,cAAe,EAKnClB,KAAK4B,eAAeX,MAAO,EAEvBpB,IAC+B,mBAAtBA,EAAQmS,YAA0BhS,KAAKiS,WAAapS,EAAQmS,WAE1C,mBAAlBnS,EAAQqS,QAAsBlS,KAAKmS,OAAStS,EAAQqS,QAIjElS,KAAK2I,GAAG,YAAakF,IAGvB,SAASA,KACP,IAAIlE,EAAQ3J,KAEe,mBAAhBA,KAAKmS,OACdnS,KAAKmS,QAAO,SAAU5P,EAAIoC,GACxByN,GAAKzI,EAAOpH,EAAIoC,MAGlByN,GAAKpS,KAAM,KAAM,MA2DrB,SAASoS,GAAKtS,EAAQyC,EAAIoC,GACxB,GAAIpC,EAAI,OAAOzC,EAAOoD,KAAK,QAASX,GAOpC,GALY,MAARoC,GACF7E,EAAO4C,KAAKiC,GAIV7E,EAAO0I,eAAe5J,OAAQ,MAAM,IAAI2E,MAAM,8CAElD,GAAIzD,EAAO4R,gBAAgBC,aAAc,MAAM,IAAIpO,MAAM,kDAEzD,OAAOzD,EAAO4C,KAAK,MA7IrBxD,GAAKG,SAAW2R,GAGhB9R,GAAKG,SAASkS,GAAWnT,IAuEzBmT,GAAUnO,UAAUV,KAAO,SAAUN,EAAOT,GAE1C,OADA3B,KAAK0R,gBAAgBI,eAAgB,EAC9B1T,GAAOgF,UAAUV,KAAKR,KAAKlC,KAAMoC,EAAOT,IAajD4P,GAAUnO,UAAU6O,WAAa,SAAU7P,EAAOT,EAAUyC,GAC1D,MAAM,IAAIb,MAAM,oCAGlBgO,GAAUnO,UAAU2J,OAAS,SAAU3K,EAAOT,EAAUyC,GACtD,IAAIqN,EAAKzR,KAAK0R,gBAId,GAHAD,EAAGxF,QAAU7H,EACbqN,EAAGG,WAAaxP,EAChBqP,EAAGM,cAAgBpQ,GACd8P,EAAGE,aAAc,CACpB,IAAIE,EAAK7R,KAAK4B,gBACV6P,EAAGK,eAAiBD,EAAG3Q,cAAgB2Q,EAAGjT,OAASiT,EAAGzR,gBAAeJ,KAAK+B,MAAM8P,EAAGzR,iBAO3FmR,GAAUnO,UAAUrB,MAAQ,SAAU0C,GACpC,IAAIgN,EAAKzR,KAAK0R,gBAEQ,OAAlBD,EAAGG,YAAuBH,EAAGxF,UAAYwF,EAAGE,cAC9CF,EAAGE,cAAe,EAClB3R,KAAKiS,WAAWR,EAAGG,WAAYH,EAAGM,cAAeN,EAAGD,iBAIpDC,EAAGK,eAAgB,GAIvBP,GAAUnO,UAAUnB,SAAW,SAAUkC,EAAKC,GAC5C,IAAIiO,EAASrS,KAEb5B,GAAOgF,UAAUnB,SAASC,KAAKlC,KAAMmE,GAAK,SAAUmO,GAClDlO,EAAGkO,GACHD,EAAOnP,KAAK,iBCzKhBqP,GAAiBC,GAEbjB,GAAYb,GAGZxR,GAAOC,OAAOC,OAAO2R,IAMzB,SAASyB,GAAY3S,GACnB,KAAMG,gBAAgBwS,IAAc,OAAO,IAAIA,GAAY3S,GAE3D0R,GAAUrP,KAAKlC,KAAMH,GARvBX,GAAKG,SAAW2R,GAGhB9R,GAAKG,SAASmT,GAAajB,IAQ3BiB,GAAYpP,UAAU6O,WAAa,SAAU7P,EAAOT,EAAUyC,GAC5DA,EAAG,KAAMhC,mBC7CXlE,EAAUD,EAAiBC,QAAAwS,IAC3B7R,OAAiBX,EACjBA,EAAAC,SAAmBD,EACnBA,EAAAyM,SAAmBoG,GACnB7S,EAAAE,OAAiB4S,GACjB9S,EAAAqT,UAAoBN,GACpB/S,EAAAsU,YAAsBtB,+DCkDtB,SAASuB,GAAUC,EAAM7S,GACxB,OAAMsQ,EAAUtQ,GAGX8S,EAAY9S,EAAS,SACzB6S,EAAKE,IAAM/S,EAAQ+S,KACb9C,EAAU4C,EAAKE,MACb,IAAI5P,UAAW6P,EAAQ,QAAS,MAAOH,EAAKE,MAGhDD,EAAY9S,EAAS,gBACzB6S,EAAKzS,WAAaJ,EAAQI,YACpByP,EAAWgD,EAAKzS,aACd,IAAI+C,UAAW6P,EAAQ,QAAS,aAAcH,EAAKzS,aAGvD0S,EAAY9S,EAAS,cACzB6S,EAAK/Q,SAAW9B,EAAQ8B,UAClBmO,EAAU4C,EAAK/Q,WAAgC,OAAlB+Q,EAAK/Q,UAChC,IAAIqB,UAAW6P,EAAQ,QAAS,WAAYH,EAAK/Q,WAGrDgR,EAAY9S,EAAS,mBACzB6S,EAAKtS,cAAgBP,EAAQO,eACvB0S,EAAeJ,EAAKtS,gBAClB,IAAI4C,UAAW6P,EAAQ,QAAS,gBAAiBH,EAAKtS,gBAG1DuS,EAAY9S,EAAS,eACzB6S,EAAKK,UAAYlT,EAAQkT,WACnBvC,EAAYkC,EAAKK,YACf,IAAI/P,UAAW6P,EAAQ,QAAS,YAAaH,EAAKK,YAGpD,KAhCC,IAAI/P,UAAW6P,EAAQ,QAAShT,QC/BrCN,UC0JJ,SAASyT,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQtT,GACvD,IAAI6S,EACAvO,EACA4C,EACJ,KAAQ/G,gBAAgBgT,IACvB,OAAKjJ,UAAUnL,OAAS,EAChB,IAAIoU,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQtT,GAEpD,IAAImT,GAAoBC,EAAGvS,EAAQwS,EAAQC,GAEnD,IAAMC,EAAsBH,GAC3B,MAAM,IAAIjQ,UAAW6P,EAAQ,QAASI,IAEvC,IAAMI,EAAc3S,GACnB,MAAM,IAAIsC,UAAW6P,EAAQ,QAASnS,IAEvC,IAAM4S,EAAWJ,GAChB,MAAM,IAAIlQ,UAAW6P,EAAQ,QAASK,IAEvC,IAAME,EAAsBD,GAC3B,MAAM,IAAInQ,UAAW6P,EAAQ,QAASM,IAEvC,GAAKF,EAAI,IACRlM,EAAIoM,GAAWF,EAAE,GAAGC,EACfC,GAAUzS,EAAO9B,QAAUmI,EAAI,GAAKA,GAAKrG,EAAO9B,QACpD,MAAM,IAAI2U,WAAYV,EAAQ,UAIhC,GADAH,EAAOpM,EAAMkN,IACRzJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EA+BR,OA3BA5E,GAAO,wEAAyEkU,KAAKC,UAAWhB,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBiB,EAAkB3T,KAAM,cAAc,GAGtC4T,EAA0B5T,KAAM,cAAe0S,EAAKzS,YAGpD2T,EAA0B5T,KAAM,OAAQ0S,EAAKE,KAG7CgB,EAA0B5T,KAAM,aAAc0S,EAAKK,WAAaU,KAAKC,WAGrEE,EAA0B5T,KAAM,UAAWU,GAG3CkT,EAA0B5T,KAAM,KAAMiT,GACtCW,EAA0B5T,KAAM,UAAWkT,GAC3CU,EAA0B5T,KAAM,UAAWmT,GAC3CQ,EAAkB3T,KAAM,OAAQmT,GAGhCQ,EAAkB3T,KAAM,KAAM,GAEvBA,KCjLR,SAASC,GAAYgT,EAAGvS,EAAQwS,EAAQC,EAAQtT,GAC/C,IAAI6S,EACJ,GAAK3I,UAAUnL,OAAS,EAAI,CAE3B,IAAMuR,EADNuC,EAAO7S,GAEN,MAAM,IAAImD,UAAW6P,EAAQ,QAASH,IAEvCA,EAAOpM,EAAMzG,EAAS,QAEtB6S,EAAO,GAGR,OADAA,EAAKzS,YAAa,EACX,IAAI+S,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQT,GCf3D,SAASmB,GAAShU,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAEDiU,EAeP,SAASA,EAAcb,EAAGvS,EAAQwS,EAAQC,GACzC,OAAO,IAAIH,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQT,IFmK5DqB,EAASf,GAAoB7U,EAAAA,QAAAA,UAY7ByV,EAA0BZ,GAAmB5P,UAAW,SApNxD,WAEC,IAAI4Q,EACA7P,EACAgN,EAEJ,IAAKnR,KAAKiU,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA7P,EAAM,KAENnE,KAAKkU,IAAM,EACNlU,KAAKkU,GAAKlU,KAAKmU,GAEnB,OAAOnU,KAAK0C,KAAM,MAEnByO,EAAInR,KAAKoU,QAASpU,KAAKqU,MACvB9U,GAAO,gCAAiCkU,KAAKC,UAAWvC,GAAKnR,KAAKqU,KAAMrU,KAAKkU,IAE7ElU,KAAKqU,MAAQrU,KAAKsU,SACQ,IAArBtU,KAAKuU,cAES,iBADlBpD,EAAInR,KAAKwU,WAAYrD,IAGnBA,EADgB,IAAZnR,KAAKkU,GACLO,EAAetD,GAEfsD,EAAezU,KAAK0U,KAAKvD,GAEnBrO,EAAUqO,GAChBnR,KAAKkU,GAAK,IACd/C,EAAIrS,EAAO2G,OAAQ,CAAEgP,EAAezU,KAAK0U,MAAQvD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB6P,EAAMhU,KAAK0C,KAAMyO,OAsLpByC,EAA0BZ,GAAmB5P,UAAW,WAxKxD,SAAkBuR,GAEjB,IAAIxP,EACJ,OAAKnF,KAAKiU,aAIV9O,EAAOnF,KACPA,KAAKiU,YAAa,EAElBpP,GASA,WACM8P,IACJpV,GAAO,mDAAsD+Q,EAASqE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHxP,EAAKjC,KAAM,QAASyR,IAGrBxP,EAAKjC,KAAM,aApBJlD,QGPT6U,EAAA/U,GAAA,aAAAG,IACA4U,EAAA/U,GAAA,UAAA+T"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 596c0c9..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 951d1035dfc9e295dec8b2705885676e70891b6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:07:33 +0000 Subject: [PATCH 007/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 --- branches.md | 53 - docs/repl.txt | 155 -- docs/types/test.ts | 189 -- examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 --- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 376 --- test/test.js | 43 - test/test.main.js | 1139 --------- test/test.object_mode.js | 279 --- test/test.validate.js | 241 -- 46 files changed, 2724 insertions(+), 6514 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c9730a4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..04bb0c7 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":";;2gIAyBIA,EAAMC,QAAQ,wBAGlBC,OAAOC,QAAUC,GAGjB,IAIIC,EAJAC,EAAUL,QAAQ,WAOtBG,GAASG,cAAgBA,GAGhBN,QAAQ,UAAUO,aAE3B,IAAIC,EAAkB,SAAUC,EAASC,GACvC,OAAOD,EAAQE,UAAUD,GAAME,QAK7BC,EAASb,QAAQ,6BAKjBc,EAASd,QAAQ,eAAec,OAChCC,EAAgBC,EAAOC,YAAc,aAWzC,IAAIC,EAAOC,OAAOC,OAAOpB,QAAQ,iBACjCkB,EAAKG,SAAWrB,QAAQ,YAIxB,IAAIsB,GAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,IAAaA,GAAUE,SACjBF,GAAUE,SAAS,UAEnB,aAIV,IAEIC,GAFAC,GAAa1B,QAAQ,iCACrB2B,GAAc3B,QAAQ,8BAG1BkB,EAAKG,SAASlB,GAAUU,GAExB,IAAIe,GAAe,CAAC,QAAS,QAAS,UAAW,QAAS,UAc1D,SAAStB,GAAcuB,EAASC,GAG9BD,EAAUA,GAAW,GAOrB,IAAIE,EAAWD,aATf1B,EAASA,GAAUJ,QAAQ,qBAa3BgC,KAAKC,aAAeJ,EAAQI,WAExBF,IAAUC,KAAKC,WAAaD,KAAKC,cAAgBJ,EAAQK,oBAI7D,IAAIC,EAAMN,EAAQO,cACdC,EAAcR,EAAQS,sBACtBC,EAAaP,KAAKC,WAAa,GAAK,MAElBD,KAAKI,cAAvBD,GAAe,IAARA,EAAgCA,EAAaJ,IAAaM,GAA+B,IAAhBA,GAAyCA,EAAsCE,EAGnKP,KAAKI,cAAgBI,KAAKC,MAAMT,KAAKI,eAKrCJ,KAAKU,OAAS,IAAIhB,GAClBM,KAAKpB,OAAS,EACdoB,KAAKW,MAAQ,KACbX,KAAKY,WAAa,EAClBZ,KAAKa,QAAU,KACfb,KAAKc,OAAQ,EACbd,KAAKe,YAAa,EAClBf,KAAKgB,SAAU,EAMfhB,KAAKiB,MAAO,EAIZjB,KAAKkB,cAAe,EACpBlB,KAAKmB,iBAAkB,EACvBnB,KAAKoB,mBAAoB,EACzBpB,KAAKqB,iBAAkB,EAGvBrB,KAAKsB,WAAY,EAKjBtB,KAAKuB,gBAAkB1B,EAAQ0B,iBAAmB,OAGlDvB,KAAKwB,WAAa,EAGlBxB,KAAKyB,aAAc,EAEnBzB,KAAK0B,QAAU,KACf1B,KAAK2B,SAAW,KACZ9B,EAAQ8B,WACLlC,KAAeA,GAAgBzB,QAAQ,mBAAmByB,eAC/DO,KAAK0B,QAAU,IAAIjC,GAAcI,EAAQ8B,UACzC3B,KAAK2B,SAAW9B,EAAQ8B,UAI5B,SAASxD,GAAS0B,GAGhB,GAFAzB,EAASA,GAAUJ,QAAQ,sBAErBgC,gBAAgB7B,IAAW,OAAO,IAAIA,GAAS0B,GAErDG,KAAK4B,eAAiB,IAAItD,GAAcuB,EAASG,MAGjDA,KAAK6B,UAAW,EAEZhC,IAC0B,mBAAjBA,EAAQiC,OAAqB9B,KAAK+B,MAAQlC,EAAQiC,MAE9B,mBAApBjC,EAAQmC,UAAwBhC,KAAKiC,SAAWpC,EAAQmC,UAGrEnD,EAAOqD,KAAKlC,MA2Dd,SAASmC,GAAiBrC,EAAQsC,EAAOT,EAAUU,EAAYC,GAC7D,IAKMC,EALFC,EAAQ1C,EAAO8B,eACL,OAAVQ,GACFI,EAAMxB,SAAU,EA0NpB,SAAoBlB,EAAQ0C,GAC1B,GAAIA,EAAM1B,MAAO,OACjB,GAAI0B,EAAMd,QAAS,CACjB,IAAIU,EAAQI,EAAMd,QAAQe,MACtBL,GAASA,EAAMxD,SACjB4D,EAAM9B,OAAOgC,KAAKN,GAClBI,EAAM5D,QAAU4D,EAAMvC,WAAa,EAAImC,EAAMxD,QAGjD4D,EAAM1B,OAAQ,EAGd6B,GAAa7C,GArOX8C,CAAW9C,EAAQ0C,KAGdF,IAAgBC,EA2CzB,SAAsBC,EAAOJ,GAC3B,IAAIG,EApPiBM,EAqPFT,EApPZtD,EAAOgE,SAASD,IAAQA,aAAe9D,GAoPA,iBAAVqD,QAAgCW,IAAVX,GAAwBI,EAAMvC,aACtFsC,EAAK,IAAIS,UAAU,oCAtPvB,IAAuBH,EAwPrB,OAAON,EAhDqBU,CAAaT,EAAOJ,IAC1CG,EACFzC,EAAOoD,KAAK,QAASX,GACZC,EAAMvC,YAAcmC,GAASA,EAAMxD,OAAS,GAChC,iBAAVwD,GAAuBI,EAAMvC,YAAcd,OAAOgE,eAAef,KAAWtD,EAAOsE,YAC5FhB,EAhNR,SAA6BA,GAC3B,OAAOtD,EAAOuE,KAAKjB,GA+MLkB,CAAoBlB,IAG1BC,EACEG,EAAMzB,WAAYjB,EAAOoD,KAAK,QAAS,IAAIK,MAAM,qCAA0CC,GAAS1D,EAAQ0C,EAAOJ,GAAO,GACrHI,EAAM1B,MACfhB,EAAOoD,KAAK,QAAS,IAAIK,MAAM,6BAE/Bf,EAAMxB,SAAU,EACZwB,EAAMd,UAAYC,GACpBS,EAAQI,EAAMd,QAAQ+B,MAAMrB,GACxBI,EAAMvC,YAA+B,IAAjBmC,EAAMxD,OAAc4E,GAAS1D,EAAQ0C,EAAOJ,GAAO,GAAYsB,GAAc5D,EAAQ0C,IAE7GgB,GAAS1D,EAAQ0C,EAAOJ,GAAO,KAGzBC,IACVG,EAAMxB,SAAU,IAIpB,OAgCF,SAAsBwB,GACpB,OAAQA,EAAM1B,QAAU0B,EAAMtB,cAAgBsB,EAAM5D,OAAS4D,EAAMpC,eAAkC,IAAjBoC,EAAM5D,QAjCnF+E,CAAanB,GAGtB,SAASgB,GAAS1D,EAAQ0C,EAAOJ,EAAOC,GAClCG,EAAM3B,SAA4B,IAAjB2B,EAAM5D,SAAiB4D,EAAMvB,MAChDnB,EAAOoD,KAAK,OAAQd,GACpBtC,EAAOgC,KAAK,KAGZU,EAAM5D,QAAU4D,EAAMvC,WAAa,EAAImC,EAAMxD,OACzCyD,EAAYG,EAAM9B,OAAOkD,QAAQxB,GAAYI,EAAM9B,OAAOgC,KAAKN,GAE/DI,EAAMtB,cAAcyB,GAAa7C,IAEvC4D,GAAc5D,EAAQ0C,GAvGxBrD,OAAO0E,eAAe1F,GAASiF,UAAW,YAAa,CACrDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAK4B,gBAGF5B,KAAK4B,eAAeN,WAE7ByC,IAAK,SAAUC,GAGRhE,KAAK4B,iBAMV5B,KAAK4B,eAAeN,UAAY0C,MAIpC7F,GAASiF,UAAUpB,QAAUrC,GAAYqC,QACzC7D,GAASiF,UAAUa,WAAatE,GAAYuE,UAC5C/F,GAASiF,UAAUnB,SAAW,SAAUkC,EAAKC,GAC3CpE,KAAK0C,KAAK,MACV0B,EAAGD,IAOLhG,GAASiF,UAAUV,KAAO,SAAUN,EAAOT,GACzC,IACIW,EADAE,EAAQxC,KAAK4B,eAgBjB,OAbKY,EAAMvC,WAUTqC,GAAiB,EATI,iBAAVF,KACTT,EAAWA,GAAYa,EAAMjB,mBACZiB,EAAMb,WACrBS,EAAQtD,EAAOuE,KAAKjB,EAAOT,GAC3BA,EAAW,IAEbW,GAAiB,GAMdH,GAAiBnC,KAAMoC,EAAOT,GAAU,EAAOW,IAIxDnE,GAASiF,UAAUQ,QAAU,SAAUxB,GACrC,OAAOD,GAAiBnC,KAAMoC,EAAO,MAAM,GAAM,IAwEnDjE,GAASiF,UAAUiB,SAAW,WAC5B,OAAuC,IAAhCrE,KAAK4B,eAAef,SAI7B1C,GAASiF,UAAUkB,YAAc,SAAUC,GAIzC,OAHK9E,KAAeA,GAAgBzB,QAAQ,mBAAmByB,eAC/DO,KAAK4B,eAAeF,QAAU,IAAIjC,GAAc8E,GAChDvE,KAAK4B,eAAeD,SAAW4C,EACxBvE,MAwBT,SAASwE,GAAcC,EAAGjC,GACxB,OAAIiC,GAAK,GAAsB,IAAjBjC,EAAM5D,QAAgB4D,EAAM1B,MAAc,EACpD0B,EAAMvC,WAAmB,EACzBwE,GAAMA,EAEJjC,EAAM3B,SAAW2B,EAAM5D,OAAe4D,EAAM9B,OAAOgE,KAAKC,KAAK/F,OAAmB4D,EAAM5D,QAGxF6F,EAAIjC,EAAMpC,gBAAeoC,EAAMpC,cA3BrC,SAAiCqE,GAc/B,OAbIA,GAFQ,QAGVA,EAHU,SAOVA,IACAA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,GACXA,KAEKA,EAa4CG,CAAwBH,IACvEA,GAAKjC,EAAM5D,OAAe6F,EAEzBjC,EAAM1B,MAIJ0B,EAAM5D,QAHX4D,EAAMtB,cAAe,EACd,IA4HX,SAASyB,GAAa7C,GACpB,IAAI0C,EAAQ1C,EAAO8B,eACnBY,EAAMtB,cAAe,EAChBsB,EAAMrB,kBACT5B,GAAM,eAAgBiD,EAAM3B,SAC5B2B,EAAMrB,iBAAkB,EACpBqB,EAAMvB,KAAMlD,EAAI8G,SAASC,GAAehF,GAAagF,GAAchF,IAI3E,SAASgF,GAAchF,GACrBP,GAAM,iBACNO,EAAOoD,KAAK,YACZ6B,GAAKjF,GASP,SAAS4D,GAAc5D,EAAQ0C,GACxBA,EAAMf,cACTe,EAAMf,aAAc,EACpB1D,EAAI8G,SAASG,GAAgBlF,EAAQ0C,IAIzC,SAASwC,GAAelF,EAAQ0C,GAE9B,IADA,IAAIyC,EAAMzC,EAAM5D,QACR4D,EAAMxB,UAAYwB,EAAM3B,UAAY2B,EAAM1B,OAAS0B,EAAM5D,OAAS4D,EAAMpC,gBAC9Eb,GAAM,wBACNO,EAAOgC,KAAK,GACRmD,IAAQzC,EAAM5D,SAELqG,EAAMzC,EAAM5D,OAE3B4D,EAAMf,aAAc,EAyOtB,SAASyD,GAAiBC,GACxB5F,GAAM,4BACN4F,EAAKrD,KAAK,GAsBZ,SAASsD,GAAQtF,EAAQ0C,GAClBA,EAAMxB,UACTzB,GAAM,iBACNO,EAAOgC,KAAK,IAGdU,EAAMnB,iBAAkB,EACxBmB,EAAMhB,WAAa,EACnB1B,EAAOoD,KAAK,UACZ6B,GAAKjF,GACD0C,EAAM3B,UAAY2B,EAAMxB,SAASlB,EAAOgC,KAAK,GAanD,SAASiD,GAAKjF,GACZ,IAAI0C,EAAQ1C,EAAO8B,eAEnB,IADArC,GAAM,OAAQiD,EAAM3B,SACb2B,EAAM3B,SAA6B,OAAlBf,EAAOgC,UAmFjC,SAASuD,GAASZ,EAAGjC,GAEnB,OAAqB,IAAjBA,EAAM5D,OAAqB,MAG3B4D,EAAMvC,WAAYqF,EAAM9C,EAAM9B,OAAO6E,SAAkBd,GAAKA,GAAKjC,EAAM5D,QAEtD0G,EAAf9C,EAAMd,QAAec,EAAM9B,OAAO8E,KAAK,IAAqC,IAAxBhD,EAAM9B,OAAO9B,OAAoB4D,EAAM9B,OAAOgE,KAAKC,KAAgBnC,EAAM9B,OAAO+E,OAAOjD,EAAM5D,QACrJ4D,EAAM9B,OAAOgF,SAGbJ,EASJ,SAAyBb,EAAGkB,EAAMC,GAChC,IAAIN,EACAb,EAAIkB,EAAKjB,KAAKC,KAAK/F,QAErB0G,EAAMK,EAAKjB,KAAKC,KAAKkB,MAAM,EAAGpB,GAC9BkB,EAAKjB,KAAKC,KAAOgB,EAAKjB,KAAKC,KAAKkB,MAAMpB,IAGtCa,EAFSb,IAAMkB,EAAKjB,KAAKC,KAAK/F,OAExB+G,EAAKJ,QAGLK,EASV,SAA8BnB,EAAGkB,GAC/B,IAAIG,EAAIH,EAAKjB,KACTqB,EAAI,EACJT,EAAMQ,EAAEnB,KACZF,GAAKa,EAAI1G,OACT,KAAOkH,EAAIA,EAAEE,MAAM,CACjB,IAAIC,EAAMH,EAAEnB,KACRuB,EAAKzB,EAAIwB,EAAIrH,OAASqH,EAAIrH,OAAS6F,EAGvC,GAFIyB,IAAOD,EAAIrH,OAAQ0G,GAAOW,EAASX,GAAOW,EAAIJ,MAAM,EAAGpB,GAEjD,KADVA,GAAKyB,GACQ,CACPA,IAAOD,EAAIrH,UACXmH,EACED,EAAEE,KAAML,EAAKjB,KAAOoB,EAAEE,KAAUL,EAAKjB,KAAOiB,EAAKQ,KAAO,OAE5DR,EAAKjB,KAAOoB,EACZA,EAAEnB,KAAOsB,EAAIJ,MAAMK,IAErB,QAEAH,EAGJ,OADAJ,EAAK/G,QAAUmH,EACRT,EAhCcc,CAAqB3B,EAAGkB,GAsC/C,SAAwBlB,EAAGkB,GACzB,IAAIL,EAAMxG,EAAOuH,YAAY5B,GACzBqB,EAAIH,EAAKjB,KACTqB,EAAI,EACRD,EAAEnB,KAAK2B,KAAKhB,GACZb,GAAKqB,EAAEnB,KAAK/F,OACZ,KAAOkH,EAAIA,EAAEE,MAAM,CACjB,IAAIO,EAAMT,EAAEnB,KACRuB,EAAKzB,EAAI8B,EAAI3H,OAAS2H,EAAI3H,OAAS6F,EAGvC,GAFA8B,EAAID,KAAKhB,EAAKA,EAAI1G,OAAS6F,EAAG,EAAGyB,GAEvB,KADVzB,GAAKyB,GACQ,CACPA,IAAOK,EAAI3H,UACXmH,EACED,EAAEE,KAAML,EAAKjB,KAAOoB,EAAEE,KAAUL,EAAKjB,KAAOiB,EAAKQ,KAAO,OAE5DR,EAAKjB,KAAOoB,EACZA,EAAEnB,KAAO4B,EAAIV,MAAMK,IAErB,QAEAH,EAGJ,OADAJ,EAAK/G,QAAUmH,EACRT,EA9D8CkB,CAAe/B,EAAGkB,GAEvE,OAAOL,EAtBCmB,CAAgBhC,EAAGjC,EAAM9B,OAAQ8B,EAAMd,SAGxC4D,GAVP,IAAIA,EA4FN,SAASoB,GAAY5G,GACnB,IAAI0C,EAAQ1C,EAAO8B,eAInB,GAAIY,EAAM5D,OAAS,EAAG,MAAM,IAAI2E,MAAM,8CAEjCf,EAAMzB,aACTyB,EAAM1B,OAAQ,EACd/C,EAAI8G,SAAS8B,GAAenE,EAAO1C,IAIvC,SAAS6G,GAAcnE,EAAO1C,GAEvB0C,EAAMzB,YAA+B,IAAjByB,EAAM5D,SAC7B4D,EAAMzB,YAAa,EACnBjB,EAAO+B,UAAW,EAClB/B,EAAOoD,KAAK,QAIhB,SAAS0D,GAAQC,EAAIC,GACnB,IAAK,IAAIC,EAAI,EAAGC,EAAIH,EAAGjI,OAAQmI,EAAIC,EAAGD,IACpC,GAAIF,EAAGE,KAAOD,EAAG,OAAOC,EAE1B,OAAQ,EApoBV5I,GAASiF,UAAUtB,KAAO,SAAU2C,GAClClF,GAAM,OAAQkF,GACdA,EAAIwC,SAASxC,EAAG,IAChB,IAAIjC,EAAQxC,KAAK4B,eACbsF,EAAQzC,EAOZ,GALU,IAANA,IAASjC,EAAMrB,iBAAkB,GAK3B,IAANsD,GAAWjC,EAAMtB,eAAiBsB,EAAM5D,QAAU4D,EAAMpC,eAAiBoC,EAAM1B,OAGjF,OAFAvB,GAAM,qBAAsBiD,EAAM5D,OAAQ4D,EAAM1B,OAC3B,IAAjB0B,EAAM5D,QAAgB4D,EAAM1B,MAAO4F,GAAY1G,MAAW2C,GAAa3C,MACpE,KAMT,GAAU,KAHVyE,EAAID,GAAcC,EAAGjC,KAGNA,EAAM1B,MAEnB,OADqB,IAAjB0B,EAAM5D,QAAc8H,GAAY1G,MAC7B,KA0BT,IA4BIsF,EA5BA6B,EAAS3E,EAAMtB,aAiDnB,OAhDA3B,GAAM,gBAAiB4H,IAGF,IAAjB3E,EAAM5D,QAAgB4D,EAAM5D,OAAS6F,EAAIjC,EAAMpC,gBAEjDb,GAAM,6BADN4H,GAAS,GAMP3E,EAAM1B,OAAS0B,EAAMxB,QAEvBzB,GAAM,mBADN4H,GAAS,GAEAA,IACT5H,GAAM,WACNiD,EAAMxB,SAAU,EAChBwB,EAAMvB,MAAO,EAEQ,IAAjBuB,EAAM5D,SAAc4D,EAAMtB,cAAe,GAE7ClB,KAAK+B,MAAMS,EAAMpC,eACjBoC,EAAMvB,MAAO,EAGRuB,EAAMxB,UAASyD,EAAID,GAAc0C,EAAO1E,KAMnC,QAFD8C,EAAPb,EAAI,EAASY,GAASZ,EAAGjC,GAAkB,OAG7CA,EAAMtB,cAAe,EACrBuD,EAAI,GAEJjC,EAAM5D,QAAU6F,EAGG,IAAjBjC,EAAM5D,SAGH4D,EAAM1B,QAAO0B,EAAMtB,cAAe,GAGnCgG,IAAUzC,GAAKjC,EAAM1B,OAAO4F,GAAY1G,OAGlC,OAARsF,GAActF,KAAKkD,KAAK,OAAQoC,GAE7BA,GAkETnH,GAASiF,UAAUrB,MAAQ,SAAU0C,GACnCzE,KAAKkD,KAAK,QAAS,IAAIK,MAAM,gCAG/BpF,GAASiF,UAAUgE,KAAO,SAAUC,EAAMC,GACxC,IAAIC,EAAMvH,KACNwC,EAAQxC,KAAK4B,eAEjB,OAAQY,EAAM5B,YACZ,KAAK,EACH4B,EAAM7B,MAAQ0G,EACd,MACF,KAAK,EACH7E,EAAM7B,MAAQ,CAAC6B,EAAM7B,MAAO0G,GAC5B,MACF,QACE7E,EAAM7B,MAAM+B,KAAK2E,GAGrB7E,EAAM5B,YAAc,EACpBrB,GAAM,wBAAyBiD,EAAM5B,WAAY0G,GAEjD,IAEIE,IAFUF,IAA6B,IAAjBA,EAAS7E,MAAkB4E,IAASI,EAAQC,QAAUL,IAASI,EAAQE,OAE7EC,EAAQC,EAI5B,SAASC,EAASjG,EAAUkG,GAC1BxI,GAAM,YACFsC,IAAa0F,GACXQ,IAAwC,IAA1BA,EAAWC,aAC3BD,EAAWC,YAAa,EAoB5BzI,GAAM,WAEN8H,EAAKY,eAAe,QAASC,GAC7Bb,EAAKY,eAAe,SAAUE,GAC9Bd,EAAKY,eAAe,QAASG,GAC7Bf,EAAKY,eAAe,QAASI,GAC7BhB,EAAKY,eAAe,SAAUH,GAC9BP,EAAIU,eAAe,MAAOL,GAC1BL,EAAIU,eAAe,MAAOJ,GAC1BN,EAAIU,eAAe,OAAQK,GAE3BC,GAAY,GAOR/F,EAAMhB,YAAgB6F,EAAKmB,iBAAkBnB,EAAKmB,eAAeC,WAAYL,KAhCnF,SAASR,IACPrI,GAAM,SACN8H,EAAK5E,MAfHD,EAAMzB,WAAYhD,EAAI8G,SAAS2C,GAAYD,EAAImB,KAAK,MAAOlB,GAE/DH,EAAKsB,GAAG,SAAUb,GAoBlB,IAAIM,EA4FN,SAAqBb,GACnB,OAAO,WACL,IAAI/E,EAAQ+E,EAAI3F,eAChBrC,GAAM,cAAeiD,EAAMhB,YACvBgB,EAAMhB,YAAYgB,EAAMhB,aACH,IAArBgB,EAAMhB,YAAoBhD,EAAgB+I,EAAK,UACjD/E,EAAM3B,SAAU,EAChBkE,GAAKwC,KAnGKqB,CAAYrB,GAC1BF,EAAKsB,GAAG,QAASP,GAEjB,IAAIG,GAAY,EA2BhB,IAAIM,GAAsB,EAE1B,SAASP,EAAOlG,GACd7C,GAAM,UACNsJ,GAAsB,GAElB,IADMxB,EAAK5D,MAAMrB,IACCyG,KAKM,IAArBrG,EAAM5B,YAAoB4B,EAAM7B,QAAU0G,GAAQ7E,EAAM5B,WAAa,IAAqC,IAAhCgG,GAAQpE,EAAM7B,MAAO0G,MAAkBkB,IACpHhJ,GAAM,8BAA+BgI,EAAI3F,eAAeJ,YACxD+F,EAAI3F,eAAeJ,aACnBqH,GAAsB,GAExBtB,EAAIuB,SAMR,SAAST,EAAQ9F,GACfhD,GAAM,UAAWgD,GACjBsF,IACAR,EAAKY,eAAe,QAASI,GACU,IAAnC7J,EAAgB6I,EAAM,UAAgBA,EAAKnE,KAAK,QAASX,GAO/D,SAAS2F,IACPb,EAAKY,eAAe,SAAUE,GAC9BN,IAGF,SAASM,IACP5I,GAAM,YACN8H,EAAKY,eAAe,QAASC,GAC7BL,IAIF,SAASA,IACPtI,GAAM,UACNgI,EAAIM,OAAOR,GAYb,OA1DAE,EAAIoB,GAAG,OAAQL,GA9gBjB,SAAyB7J,EAASsK,EAAOC,GAGvC,GAAuC,mBAA5BvK,EAAQwK,gBAAgC,OAAOxK,EAAQwK,gBAAgBF,EAAOC,GAMpFvK,EAAQyK,SAAYzK,EAAQyK,QAAQH,GAAuC1K,EAAQI,EAAQyK,QAAQH,IAAStK,EAAQyK,QAAQH,GAAOnF,QAAQoF,GAASvK,EAAQyK,QAAQH,GAAS,CAACC,EAAIvK,EAAQyK,QAAQH,IAAtJtK,EAAQkK,GAAGI,EAAOC,GAkiBnEC,CAAgB5B,EAAM,QAASgB,GAO/BhB,EAAKqB,KAAK,QAASR,GAMnBb,EAAKqB,KAAK,SAAUP,GAQpBd,EAAKnE,KAAK,OAAQqE,GAGb/E,EAAM3B,UACTtB,GAAM,eACNgI,EAAI4B,UAGC9B,GAeTlJ,GAASiF,UAAUyE,OAAS,SAAUR,GACpC,IAAI7E,EAAQxC,KAAK4B,eACbmG,EAAa,CAAEC,YAAY,GAG/B,GAAyB,IAArBxF,EAAM5B,WAAkB,OAAOZ,KAGnC,GAAyB,IAArBwC,EAAM5B,WAER,OAAIyG,GAAQA,IAAS7E,EAAM7B,QAEtB0G,IAAMA,EAAO7E,EAAM7B,OAGxB6B,EAAM7B,MAAQ,KACd6B,EAAM5B,WAAa,EACnB4B,EAAM3B,SAAU,EACZwG,GAAMA,EAAKnE,KAAK,SAAUlD,KAAM+H,IARK/H,KAc3C,IAAKqH,EAAM,CAET,IAAI+B,EAAQ5G,EAAM7B,MACdsE,EAAMzC,EAAM5B,WAChB4B,EAAM7B,MAAQ,KACd6B,EAAM5B,WAAa,EACnB4B,EAAM3B,SAAU,EAEhB,IAAK,IAAIkG,EAAI,EAAGA,EAAI9B,EAAK8B,IACvBqC,EAAMrC,GAAG7D,KAAK,SAAUlD,KAAM+H,GAC/B,OAAO/H,KAIV,IAAIqJ,EAAQzC,GAAQpE,EAAM7B,MAAO0G,GACjC,OAAe,IAAXgC,IAEJ7G,EAAM7B,MAAM2I,OAAOD,EAAO,GAC1B7G,EAAM5B,YAAc,EACK,IAArB4B,EAAM5B,aAAkB4B,EAAM7B,MAAQ6B,EAAM7B,MAAM,IAEtD0G,EAAKnE,KAAK,SAAUlD,KAAM+H,IAND/H,MAa3B7B,GAASiF,UAAUuF,GAAK,SAAUY,EAAIP,GACpC,IAAIQ,EAAM3K,EAAOuE,UAAUuF,GAAGzG,KAAKlC,KAAMuJ,EAAIP,GAE7C,GAAW,SAAPO,GAEkC,IAAhCvJ,KAAK4B,eAAef,SAAmBb,KAAKmJ,cAC3C,GAAW,aAAPI,EAAmB,CAC5B,IAAI/G,EAAQxC,KAAK4B,eACZY,EAAMzB,YAAeyB,EAAMpB,oBAC9BoB,EAAMpB,kBAAoBoB,EAAMtB,cAAe,EAC/CsB,EAAMrB,iBAAkB,EACnBqB,EAAMxB,QAEAwB,EAAM5D,QACf+D,GAAa3C,MAFbjC,EAAI8G,SAASK,GAAkBlF,OAOrC,OAAOwJ,GAETrL,GAASiF,UAAUqG,YAActL,GAASiF,UAAUuF,GASpDxK,GAASiF,UAAU+F,OAAS,WAC1B,IAAI3G,EAAQxC,KAAK4B,eAMjB,OALKY,EAAM3B,UACTtB,GAAM,UACNiD,EAAM3B,SAAU,EAMpB,SAAgBf,EAAQ0C,GACjBA,EAAMnB,kBACTmB,EAAMnB,iBAAkB,EACxBtD,EAAI8G,SAASO,GAAStF,EAAQ0C,IAR9B2G,CAAOnJ,KAAMwC,IAERxC,MAuBT7B,GAASiF,UAAU0F,MAAQ,WAOzB,OANAvJ,GAAM,wBAAyBS,KAAK4B,eAAef,UAC/C,IAAUb,KAAK4B,eAAef,UAChCtB,GAAM,SACNS,KAAK4B,eAAef,SAAU,EAC9Bb,KAAKkD,KAAK,UAELlD,MAYT7B,GAASiF,UAAUsG,KAAO,SAAU5J,GAClC,IAAI6J,EAAQ3J,KAERwC,EAAQxC,KAAK4B,eACbgI,GAAS,EA4Bb,IAAK,IAAI7C,KA1BTjH,EAAO6I,GAAG,OAAO,WAEf,GADApJ,GAAM,eACFiD,EAAMd,UAAYc,EAAM1B,MAAO,CACjC,IAAIsB,EAAQI,EAAMd,QAAQe,MACtBL,GAASA,EAAMxD,QAAQ+K,EAAMjH,KAAKN,GAGxCuH,EAAMjH,KAAK,SAGb5C,EAAO6I,GAAG,QAAQ,SAAUvG,IAC1B7C,GAAM,gBACFiD,EAAMd,UAASU,EAAQI,EAAMd,QAAQ+B,MAAMrB,IAG3CI,EAAMvC,YAAe,MAAAmC,KAAyDI,EAAMvC,YAAgBmC,GAAUA,EAAMxD,UAE9G+K,EAAMjH,KAAKN,KAEnBwH,GAAS,EACT9J,EAAOgJ,aAMGhJ,OACIiD,IAAZ/C,KAAK+G,IAAyC,mBAAdjH,EAAOiH,KACzC/G,KAAK+G,GAAK,SAAU8C,GAClB,OAAO,WACL,OAAO/J,EAAO+J,GAAQC,MAAMhK,EAAQiK,YAF9B,CAIRhD,IAKN,IAAK,IAAItC,EAAI,EAAGA,EAAI7E,GAAahB,OAAQ6F,IACvC3E,EAAO6I,GAAG/I,GAAa6E,GAAIzE,KAAKkD,KAAK8G,KAAKhK,KAAMJ,GAAa6E,KAa/D,OARAzE,KAAK+B,MAAQ,SAAU0C,GACrBlF,GAAM,gBAAiBkF,GACnBmF,IACFA,GAAS,EACT9J,EAAOqJ,WAIJnJ,MAGTb,OAAO0E,eAAe1F,GAASiF,UAAW,wBAAyB,CAIjE6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAK4B,eAAexB,iBAK/BjC,GAAS+L,UAAY7E,6CC51BjBtH,GAAMC,QAAQ,wBAelB,SAASmM,GAAc3H,GACrB,IAAImH,EAAQ3J,KAEZA,KAAKgG,KAAO,KACZhG,KAAKoK,MAAQ,KACbpK,KAAKqK,OAAS,YAolBhB,SAAwBC,EAAS9H,EAAO2B,GACtC,IAAIiG,EAAQE,EAAQF,MACpBE,EAAQF,MAAQ,KAChB,KAAOA,GAAO,CACZ,IAAIhG,EAAKgG,EAAMG,SACf/H,EAAMgI,YACNpG,EAAGD,GACHiG,EAAQA,EAAMpE,KAEZxD,EAAMiI,mBACRjI,EAAMiI,mBAAmBzE,KAAOsE,EAEhC9H,EAAMiI,mBAAqBH,EA/lB3BI,CAAef,EAAOnH,IAlB1BvE,OAAOC,QAAUyM,GAwBjB,IAIIvM,GAJAwM,IAAcnD,EAAQoD,SAAW,CAAC,QAAS,SAASjE,QAAQa,EAAQqD,QAAQjF,MAAM,EAAG,KAAO,EAAIkF,aAAehN,GAAI8G,SAOvH8F,GAASK,cAAgBA,GAGzB,IAAI9L,GAAOC,OAAOC,OAAOpB,QAAQ,iBACjCkB,GAAKG,SAAWrB,QAAQ,YAIxB,IAAIiN,GAAe,CACjBC,UAAWlN,QAAQ,mBAKjBa,GAASb,QAAQ,6BAKjBc,GAASd,QAAQ,eAAec,OAChCC,GAAgBC,EAAOC,YAAc,aAUzC,IA2IIkM,GA3IAxL,GAAc3B,QAAQ,8BAI1B,SAASoN,MAET,SAASJ,GAAcnL,EAASC,GAC9B1B,GAASA,IAAUJ,QAAQ,oBAE3B6B,EAAUA,GAAW,GAOrB,IAAIE,EAAWD,aAAkB1B,GAIjC4B,KAAKC,aAAeJ,EAAQI,WAExBF,IAAUC,KAAKC,WAAaD,KAAKC,cAAgBJ,EAAQwL,oBAK7D,IAAIlL,EAAMN,EAAQO,cACdkL,EAAczL,EAAQ0L,sBACtBhL,EAAaP,KAAKC,WAAa,GAAK,MAElBD,KAAKI,cAAvBD,GAAe,IAARA,EAAgCA,EAAaJ,IAAauL,GAA+B,IAAhBA,GAAyCA,EAAsC/K,EAGnKP,KAAKI,cAAgBI,KAAKC,MAAMT,KAAKI,eAGrCJ,KAAKwL,aAAc,EAGnBxL,KAAKyI,WAAY,EAEjBzI,KAAKyL,QAAS,EAEdzL,KAAKc,OAAQ,EAEbd,KAAK0L,UAAW,EAGhB1L,KAAKsB,WAAY,EAKjB,IAAIqK,GAAqC,IAA1B9L,EAAQ+L,cACvB5L,KAAK4L,eAAiBD,EAKtB3L,KAAKuB,gBAAkB1B,EAAQ0B,iBAAmB,OAKlDvB,KAAKpB,OAAS,EAGdoB,KAAK6L,SAAU,EAGf7L,KAAK8L,OAAS,EAMd9L,KAAKiB,MAAO,EAKZjB,KAAK+L,kBAAmB,EAGxB/L,KAAKgM,QAAU,SAAUzJ,IA4R3B,SAAiBzC,EAAQyC,GACvB,IAAIC,EAAQ1C,EAAO0I,eACfvH,EAAOuB,EAAMvB,KACbmD,EAAK5B,EAAMyJ,QAIf,GAdF,SAA4BzJ,GAC1BA,EAAMqJ,SAAU,EAChBrJ,EAAMyJ,QAAU,KAChBzJ,EAAM5D,QAAU4D,EAAM0J,SACtB1J,EAAM0J,SAAW,EAQjBC,CAAmB3J,GAEfD,GAtCN,SAAsBzC,EAAQ0C,EAAOvB,EAAMsB,EAAI6B,KAC3C5B,EAAMgI,UAEJvJ,GAGFlD,GAAI8G,SAAST,EAAI7B,GAGjBxE,GAAI8G,SAASuH,GAAatM,EAAQ0C,GAClC1C,EAAO0I,eAAe6D,cAAe,EACrCvM,EAAOoD,KAAK,QAASX,KAIrB6B,EAAG7B,GACHzC,EAAO0I,eAAe6D,cAAe,EACrCvM,EAAOoD,KAAK,QAASX,GAGrB6J,GAAYtM,EAAQ0C,IAkBd8J,CAAaxM,EAAQ0C,EAAOvB,EAAMsB,EAAI6B,OAAS,CAErD,IAAIsH,EAAWa,GAAW/J,GAErBkJ,GAAalJ,EAAMsJ,QAAWtJ,EAAMuJ,mBAAoBvJ,EAAMgK,iBACjEC,GAAY3M,EAAQ0C,GAGlBvB,EAEF2J,GAAW8B,GAAY5M,EAAQ0C,EAAOkJ,EAAUtH,GAGhDsI,GAAW5M,EAAQ0C,EAAOkJ,EAAUtH,IA/StC4H,CAAQlM,EAAQyC,IAIlBvC,KAAKiM,QAAU,KAGfjM,KAAKkM,SAAW,EAEhBlM,KAAKwM,gBAAkB,KACvBxM,KAAK2M,oBAAsB,KAI3B3M,KAAKwK,UAAY,EAIjBxK,KAAK4M,aAAc,EAGnB5M,KAAKqM,cAAe,EAGpBrM,KAAK6M,qBAAuB,EAI5B7M,KAAKyK,mBAAqB,IAAIN,GAAcnK,MA0C9C,SAAS2K,GAAS9K,GAUhB,GATAzB,GAASA,IAAUJ,QAAQ,sBAStBmN,GAAgBjJ,KAAKyI,GAAU3K,OAAWA,gBAAgB5B,IAC7D,OAAO,IAAIuM,GAAS9K,GAGtBG,KAAKwI,eAAiB,IAAIwC,GAAcnL,EAASG,MAGjDA,KAAK8M,UAAW,EAEZjN,IAC2B,mBAAlBA,EAAQ4D,QAAsBzD,KAAK+M,OAASlN,EAAQ4D,OAEjC,mBAAnB5D,EAAQmN,SAAuBhN,KAAKiN,QAAUpN,EAAQmN,QAElC,mBAApBnN,EAAQmC,UAAwBhC,KAAKiC,SAAWpC,EAAQmC,SAEtC,mBAAlBnC,EAAQqN,QAAsBlN,KAAKmN,OAAStN,EAAQqN,QAGjErO,GAAOqD,KAAKlC,MAgJd,SAASoN,GAAQtN,EAAQ0C,EAAOwK,EAAQ/H,EAAK7C,EAAOT,EAAUyC,GAC5D5B,EAAM0J,SAAWjH,EACjBzC,EAAMyJ,QAAU7H,EAChB5B,EAAMqJ,SAAU,EAChBrJ,EAAMvB,MAAO,EACT+L,EAAQlN,EAAOmN,QAAQ7K,EAAOI,EAAMwJ,SAAclM,EAAOiN,OAAO3K,EAAOT,EAAUa,EAAMwJ,SAC3FxJ,EAAMvB,MAAO,EA2Df,SAASyL,GAAW5M,EAAQ0C,EAAOkJ,EAAUtH,GACtCsH,GASP,SAAsB5L,EAAQ0C,GACP,IAAjBA,EAAM5D,QAAgB4D,EAAMiG,YAC9BjG,EAAMiG,WAAY,EAClB3I,EAAOoD,KAAK,UAZCmK,CAAavN,EAAQ0C,GACpCA,EAAMgI,YACNpG,IACAgI,GAAYtM,EAAQ0C,GActB,SAASiK,GAAY3M,EAAQ0C,GAC3BA,EAAMuJ,kBAAmB,EACzB,IAAI3B,EAAQ5H,EAAMgK,gBAElB,GAAI1M,EAAOmN,SAAW7C,GAASA,EAAMpE,KAAM,CAEzC,IAAIgB,EAAIxE,EAAMqK,qBACVnM,EAAS,IAAI4M,MAAMtG,GACnBuG,EAAS/K,EAAMiI,mBACnB8C,EAAOnD,MAAQA,EAIf,IAFA,IAAIoD,EAAQ,EACRC,GAAa,EACVrD,GACL1J,EAAO8M,GAASpD,EACXA,EAAMsD,QAAOD,GAAa,GAC/BrD,EAAQA,EAAMpE,KACdwH,GAAS,EAEX9M,EAAO+M,WAAaA,EAEpBL,GAAQtN,EAAQ0C,GAAO,EAAMA,EAAM5D,OAAQ8B,EAAQ,GAAI6M,EAAOlD,QAI9D7H,EAAMgI,YACNhI,EAAMmK,oBAAsB,KACxBY,EAAOvH,MACTxD,EAAMiI,mBAAqB8C,EAAOvH,KAClCuH,EAAOvH,KAAO,MAEdxD,EAAMiI,mBAAqB,IAAIN,GAAc3H,GAE/CA,EAAMqK,qBAAuB,MACxB,CAEL,KAAOzC,GAAO,CACZ,IAAIhI,EAAQgI,EAAMhI,MACdT,EAAWyI,EAAMzI,SACjByC,EAAKgG,EAAMG,SAUf,GAPA6C,GAAQtN,EAAQ0C,GAAO,EAFbA,EAAMvC,WAAa,EAAImC,EAAMxD,OAEJwD,EAAOT,EAAUyC,GACpDgG,EAAQA,EAAMpE,KACdxD,EAAMqK,uBAKFrK,EAAMqJ,QACR,MAIU,OAAVzB,IAAgB5H,EAAMmK,oBAAsB,MAGlDnK,EAAMgK,gBAAkBpC,EACxB5H,EAAMuJ,kBAAmB,EAiC3B,SAASQ,GAAW/J,GAClB,OAAOA,EAAMiJ,QAA2B,IAAjBjJ,EAAM5D,QAA0C,OAA1B4D,EAAMgK,kBAA6BhK,EAAMkJ,WAAalJ,EAAMqJ,QAE3G,SAAS8B,GAAU7N,EAAQ0C,GACzB1C,EAAOqN,QAAO,SAAUhJ,GACtB3B,EAAMgI,YACFrG,GACFrE,EAAOoD,KAAK,QAASiB,GAEvB3B,EAAMoK,aAAc,EACpB9M,EAAOoD,KAAK,aACZkJ,GAAYtM,EAAQ0C,MAgBxB,SAAS4J,GAAYtM,EAAQ0C,GAC3B,IAAIoL,EAAOrB,GAAW/J,GAQtB,OAPIoL,KAfN,SAAmB9N,EAAQ0C,GACpBA,EAAMoK,aAAgBpK,EAAMgJ,cACF,mBAAlB1L,EAAOqN,QAChB3K,EAAMgI,YACNhI,EAAMgJ,aAAc,EACpBzN,GAAI8G,SAAS8I,GAAW7N,EAAQ0C,KAEhCA,EAAMoK,aAAc,EACpB9M,EAAOoD,KAAK,eAQd2K,CAAU/N,EAAQ0C,GACM,IAApBA,EAAMgI,YACRhI,EAAMkJ,UAAW,EACjB5L,EAAOoD,KAAK,YAGT0K,EAzhBT1O,GAAKG,SAASsL,GAAU9L,IAmHxBmM,GAAc5H,UAAU0K,UAAY,WAGlC,IAFA,IAAIC,EAAU/N,KAAKwM,gBACfwB,EAAM,GACHD,GACLC,EAAItL,KAAKqL,GACTA,EAAUA,EAAQ/H,KAEpB,OAAOgI,GAGT,WACE,IACE7O,OAAO0E,eAAemH,GAAc5H,UAAW,SAAU,CACvDU,IAAKmH,GAAaC,WAAU,WAC1B,OAAOlL,KAAK8N,cACX,6EAAmF,aAExF,MAAOG,KAPX,GAasB,mBAAXC,QAAyBA,OAAOC,aAAiE,mBAA3CC,SAAShL,UAAU8K,OAAOC,cACzFhD,GAAkBiD,SAAShL,UAAU8K,OAAOC,aAC5ChP,OAAO0E,eAAe8G,GAAUuD,OAAOC,YAAa,CAClDnK,MAAO,SAAUqK,GACf,QAAIlD,GAAgBjJ,KAAKlC,KAAMqO,IAC3BrO,OAAS2K,KAEN0D,GAAUA,EAAO7F,0BAA0BwC,QAItDG,GAAkB,SAAUkD,GAC1B,OAAOA,aAAkBrO,MAqC7B2K,GAASvH,UAAUgE,KAAO,WACxBpH,KAAKkD,KAAK,QAAS,IAAIK,MAAM,+BA8B/BoH,GAASvH,UAAUK,MAAQ,SAAUrB,EAAOT,EAAUyC,GACpD,IAnOqBvB,EAmOjBL,EAAQxC,KAAKwI,eACblD,GAAM,EACNoI,GAASlL,EAAMvC,aArOE4C,EAqO0BT,EApOxCtD,GAAOgE,SAASD,IAAQA,aAAe9D,IAwP9C,OAlBI2O,IAAU5O,GAAOgE,SAASV,KAC5BA,EA3OJ,SAA6BA,GAC3B,OAAOtD,GAAOuE,KAAKjB,GA0OTkB,CAAoBlB,IAGN,mBAAbT,IACTyC,EAAKzC,EACLA,EAAW,MAGT+L,EAAO/L,EAAW,SAAmBA,IAAUA,EAAWa,EAAMjB,iBAElD,mBAAP6C,IAAmBA,EAAKgH,IAE/B5I,EAAM1B,MA7CZ,SAAuBhB,EAAQsE,GAC7B,IAAI7B,EAAK,IAAIgB,MAAM,mBAEnBzD,EAAOoD,KAAK,QAASX,GACrBxE,GAAI8G,SAAST,EAAI7B,GAyCA+L,CAActO,KAAMoE,IAAasJ,GAnCpD,SAAoB5N,EAAQ0C,EAAOJ,EAAOgC,GACxC,IAAImK,GAAQ,EACRhM,GAAK,EAYT,OAVc,OAAVH,EACFG,EAAK,IAAIS,UAAU,uCACO,iBAAVZ,QAAgCW,IAAVX,GAAwBI,EAAMvC,aACpEsC,EAAK,IAAIS,UAAU,oCAEjBT,IACFzC,EAAOoD,KAAK,QAASX,GACrBxE,GAAI8G,SAAST,EAAI7B,GACjBgM,GAAQ,GAEHA,EAqBoDC,CAAWxO,KAAMwC,EAAOJ,EAAOgC,MACxF5B,EAAMgI,YACNlF,EAkDJ,SAAuBxF,EAAQ0C,EAAOkL,EAAOtL,EAAOT,EAAUyC,GAC5D,IAAKsJ,EAAO,CACV,IAAIe,EAtBR,SAAqBjM,EAAOJ,EAAOT,GAC5Ba,EAAMvC,aAAsC,IAAxBuC,EAAMoJ,eAA4C,iBAAVxJ,IAC/DA,EAAQtD,GAAOuE,KAAKjB,EAAOT,IAE7B,OAAOS,EAkBUsM,CAAYlM,EAAOJ,EAAOT,GACrCS,IAAUqM,IACZf,GAAQ,EACR/L,EAAW,SACXS,EAAQqM,GAGZ,IAAIxJ,EAAMzC,EAAMvC,WAAa,EAAImC,EAAMxD,OAEvC4D,EAAM5D,QAAUqG,EAEhB,IAAIK,EAAM9C,EAAM5D,OAAS4D,EAAMpC,cAE1BkF,IAAK9C,EAAMiG,WAAY,GAE5B,GAAIjG,EAAMqJ,SAAWrJ,EAAMsJ,OAAQ,CACjC,IAAI6C,EAAOnM,EAAMmK,oBACjBnK,EAAMmK,oBAAsB,CAC1BvK,MAAOA,EACPT,SAAUA,EACV+L,MAAOA,EACPnD,SAAUnG,EACV4B,KAAM,MAEJ2I,EACFA,EAAK3I,KAAOxD,EAAMmK,oBAElBnK,EAAMgK,gBAAkBhK,EAAMmK,oBAEhCnK,EAAMqK,sBAAwB,OAE9BO,GAAQtN,EAAQ0C,GAAO,EAAOyC,EAAK7C,EAAOT,EAAUyC,GAGtD,OAAOkB,EAtFCsJ,CAAc5O,KAAMwC,EAAOkL,EAAOtL,EAAOT,EAAUyC,IAGpDkB,GAGTqF,GAASvH,UAAUyL,KAAO,WACZ7O,KAAKwI,eAEXsD,UAGRnB,GAASvH,UAAU0L,OAAS,WAC1B,IAAItM,EAAQxC,KAAKwI,eAEbhG,EAAMsJ,SACRtJ,EAAMsJ,SAEDtJ,EAAMqJ,SAAYrJ,EAAMsJ,QAAWtJ,EAAMkJ,UAAalJ,EAAMuJ,mBAAoBvJ,EAAMgK,iBAAiBC,GAAYzM,KAAMwC,KAIlImI,GAASvH,UAAU2L,mBAAqB,SAA4BpN,GAGlE,GADwB,iBAAbA,IAAuBA,EAAWA,EAASqN,iBAChD,CAAC,MAAO,OAAQ,QAAS,QAAS,SAAU,SAAU,OAAQ,QAAS,UAAW,WAAY,OAAOpI,SAASjF,EAAW,IAAIqN,gBAAkB,GAAI,MAAM,IAAIhM,UAAU,qBAAuBrB,GAEpM,OADA3B,KAAKwI,eAAejH,gBAAkBI,EAC/B3B,MAUTb,OAAO0E,eAAe8G,GAASvH,UAAW,wBAAyB,CAIjE6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAKwI,eAAepI,iBA8L/BuK,GAASvH,UAAU2J,OAAS,SAAU3K,EAAOT,EAAUyC,GACrDA,EAAG,IAAIb,MAAM,iCAGfoH,GAASvH,UAAU6J,QAAU,KAE7BtC,GAASvH,UAAUX,IAAM,SAAUL,EAAOT,EAAUyC,GAClD,IAAI5B,EAAQxC,KAAKwI,eAEI,mBAAVpG,GACTgC,EAAKhC,EACLA,EAAQ,KACRT,EAAW,MACkB,mBAAbA,IAChByC,EAAKzC,EACLA,EAAW,MAGTS,SAAuCpC,KAAKyD,MAAMrB,EAAOT,GAGzDa,EAAMsJ,SACRtJ,EAAMsJ,OAAS,EACf9L,KAAK8O,UAIFtM,EAAMiJ,QAAWjJ,EAAMkJ,UA0C9B,SAAqB5L,EAAQ0C,EAAO4B,GAClC5B,EAAMiJ,QAAS,EACfW,GAAYtM,EAAQ0C,GAChB4B,IACE5B,EAAMkJ,SAAU3N,GAAI8G,SAAST,GAAStE,EAAO4I,KAAK,SAAUtE,IAElE5B,EAAM1B,OAAQ,EACdhB,EAAOgN,UAAW,EAjDoBmC,CAAYjP,KAAMwC,EAAO4B,IAoEjEjF,OAAO0E,eAAe8G,GAASvH,UAAW,YAAa,CACrDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAKwI,gBAGFxI,KAAKwI,eAAelH,WAE7ByC,IAAK,SAAUC,GAGRhE,KAAKwI,iBAMVxI,KAAKwI,eAAelH,UAAY0C,MAIpC2G,GAASvH,UAAUpB,QAAUrC,GAAYqC,QACzC2I,GAASvH,UAAUa,WAAatE,GAAYuE,UAC5CyG,GAASvH,UAAUnB,SAAW,SAAUkC,EAAKC,GAC3CpE,KAAKyC,MACL2B,EAAGD,mDC3qBkB,IAAZsD,IACNA,EAAQqD,SAC0B,IAAnCrD,EAAQqD,QAAQlE,QAAQ,QACW,IAAnCa,EAAQqD,QAAQlE,QAAQ,QAAqD,IAArCa,EAAQqD,QAAQlE,QAAQ,SAClE3I,OAAOC,QAAU,CAAE2G,SAKrB,SAAkBmE,EAAIkG,EAAMC,EAAMC,GAChC,GAAkB,mBAAPpG,EACT,MAAM,IAAIhG,UAAU,0CAEtB,IACIqM,EAAMtI,EADN9B,EAAM8E,UAAUnL,OAEpB,OAAQqG,GACR,KAAK,EACL,KAAK,EACH,OAAOwC,EAAQ5C,SAASmE,GAC1B,KAAK,EACH,OAAOvB,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,MAElB,KAAK,EACH,OAAOzH,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,EAAMC,MAExB,KAAK,EACH,OAAO1H,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,EAAMC,EAAMC,MAE9B,QAGE,IAFAC,EAAO,IAAI/B,MAAMrI,EAAM,GACvB8B,EAAI,EACGA,EAAIsI,EAAKzQ,QACdyQ,EAAKtI,KAAOgD,UAAUhD,GAExB,OAAOU,EAAQ5C,UAAS,WACtBmE,EAAGc,MAAM,KAAMuF,SAhCnBpR,OAAOC,QAAUuJ,y6qBCgGnB,SAAS6H,GAAeC,GACtB,OAAOpQ,OAAOiE,UAAUoM,SAAStN,KAAKqN,GA3EzBrQ,GAAAb,QANf,SAAiBoR,GACf,OAAInC,MAAMjP,QACDiP,MAAMjP,QAAQoR,GAEQ,mBAAxBH,GAAeG,IAOPvQ,GAAAwQ,UAHjB,SAAmBD,GACjB,MAAsB,kBAARA,GAOFvQ,GAAAyQ,OAHd,SAAgBF,GACd,OAAe,OAARA,GAOgBvQ,GAAA0Q,kBAHzB,SAA2BH,GACzB,OAAc,MAAPA,GAOOvQ,GAAA2Q,SAHhB,SAAkBJ,GAChB,MAAsB,iBAARA,GAOAvQ,GAAA4Q,SAHhB,SAAkBL,GAChB,MAAsB,iBAARA,GAOAvQ,GAAA6Q,SAHhB,SAAkBN,GAChB,MAAsB,iBAARA,GAOGvQ,GAAA8Q,YAHnB,SAAqBP,GACnB,YAAe,IAARA,GAOOvQ,GAAA+Q,SAHhB,SAAkBC,GAChB,MAA8B,oBAAvBZ,GAAeY,IAORhR,GAAAiR,SAHhB,SAAkBV,GAChB,MAAsB,iBAARA,GAA4B,OAARA,GAOtBvQ,GAAAkR,OAHd,SAAgBC,GACd,MAA6B,kBAAtBf,GAAee,IAOTnR,GAAAoR,QAHf,SAAiBC,GACf,MAA8B,mBAAtBjB,GAAeiB,IAA2BA,aAAahN,OAO/CrE,GAAAsR,WAHlB,SAAoBf,GAClB,MAAsB,mBAARA,GAYGvQ,GAAAuR,YARnB,SAAqBhB,GACnB,OAAe,OAARA,GACe,kBAARA,GACQ,iBAARA,GACQ,iBAARA,GACQ,iBAARA,QACQ,IAARA,GAIhBvQ,GAAA4D,SAAmB4N,GAAkB5R,OAAOgE,sVCxExC/E,GAAM2S,GAINC,GAAaxR,OAAOyR,MAAQ,SAAU/N,GACxC,IAAI+N,EAAO,GACX,IAAK,IAAIC,KAAOhO,EACd+N,EAAKlO,KAAKmO,GACX,OAAOD,GAIVE,GAAiB1S,GAGbc,GAAOC,OAAOC,OAAO2R,IACzB7R,GAAKG,SAAW2R,GAGhB,IAAI7S,GAAW8S,GACXtG,GAAWuG,GAEfhS,GAAKG,SAASjB,GAAQD,IAKpB,IADA,IAAIyS,GAAOD,GAAWhG,GAASvH,WACtB+N,GAAI,EAAGA,GAAIP,GAAKhS,OAAQuS,KAAK,CACpC,IAAItH,GAAS+G,GAAKO,IACb/S,GAAOgF,UAAUyG,MAASzL,GAAOgF,UAAUyG,IAAUc,GAASvH,UAAUyG,KAIjF,SAASzL,GAAOyB,GACd,KAAMG,gBAAgB5B,IAAS,OAAO,IAAIA,GAAOyB,GAEjD1B,GAAS+D,KAAKlC,KAAMH,GACpB8K,GAASzI,KAAKlC,KAAMH,GAEhBA,IAAgC,IAArBA,EAAQgC,WAAoB7B,KAAK6B,UAAW,GAEvDhC,IAAgC,IAArBA,EAAQiN,WAAoB9M,KAAK8M,UAAW,GAE3D9M,KAAKoR,eAAgB,EACjBvR,IAAqC,IAA1BA,EAAQuR,gBAAyBpR,KAAKoR,eAAgB,GAErEpR,KAAK0I,KAAK,MAAOd,IAcnB,SAASA,KAGH5H,KAAKoR,eAAiBpR,KAAKwI,eAAe1H,OAI9C/C,GAAI8G,SAASwM,GAASrR,MAGxB,SAASqR,GAAQlM,GACfA,EAAK1C,MAtBPtD,OAAO0E,eAAezF,GAAOgF,UAAW,wBAAyB,CAI/D6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAKwI,eAAepI,iBAmB/BjB,OAAO0E,eAAezF,GAAOgF,UAAW,YAAa,CACnDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAK4B,qBAAwDmB,IAAxB/C,KAAKwI,iBAGvCxI,KAAK4B,eAAeN,WAAatB,KAAKwI,eAAelH,YAE9DyC,IAAK,SAAUC,QAGejB,IAAxB/C,KAAK4B,qBAAwDmB,IAAxB/C,KAAKwI,iBAM9CxI,KAAK4B,eAAeN,UAAY0C,EAChChE,KAAKwI,eAAelH,UAAY0C,MAIpC5F,GAAOgF,UAAUnB,SAAW,SAAUkC,EAAKC,GACzCpE,KAAK0C,KAAK,MACV1C,KAAKyC,MAEL1E,GAAI8G,SAAST,EAAID,QChEnBmN,GAAiBC,GAEbnT,GAASsS,GAGTxR,GAAOC,OAAOC,OAAO2R,IAMzB,SAASS,GAAejP,EAAIoC,GAC1B,IAAI8M,EAAKzR,KAAK0R,gBACdD,EAAGE,cAAe,EAElB,IAAIvN,EAAKqN,EAAGxF,QAEZ,IAAK7H,EACH,OAAOpE,KAAKkD,KAAK,QAAS,IAAIK,MAAM,yCAGtCkO,EAAGG,WAAa,KAChBH,EAAGxF,QAAU,KAED,MAARtH,GACF3E,KAAK0C,KAAKiC,GAEZP,EAAG7B,GAEH,IAAIsP,EAAK7R,KAAK4B,eACdiQ,EAAG7Q,SAAU,GACT6Q,EAAG3Q,cAAgB2Q,EAAGjT,OAASiT,EAAGzR,gBACpCJ,KAAK+B,MAAM8P,EAAGzR,eAIlB,SAASmR,GAAU1R,GACjB,KAAMG,gBAAgBuR,IAAY,OAAO,IAAIA,GAAU1R,GAEvDzB,GAAO8D,KAAKlC,KAAMH,GAElBG,KAAK0R,gBAAkB,CACrBF,eAAgBA,GAAexH,KAAKhK,MACpC8R,eAAe,EACfH,cAAc,EACd1F,QAAS,KACT2F,WAAY,KACZG,cAAe,MAIjB/R,KAAK4B,eAAeV,cAAe,EAKnClB,KAAK4B,eAAeX,MAAO,EAEvBpB,IAC+B,mBAAtBA,EAAQmS,YAA0BhS,KAAKiS,WAAapS,EAAQmS,WAE1C,mBAAlBnS,EAAQqS,QAAsBlS,KAAKmS,OAAStS,EAAQqS,QAIjElS,KAAK2I,GAAG,YAAakF,IAGvB,SAASA,KACP,IAAIlE,EAAQ3J,KAEe,mBAAhBA,KAAKmS,OACdnS,KAAKmS,QAAO,SAAU5P,EAAIoC,GACxByN,GAAKzI,EAAOpH,EAAIoC,MAGlByN,GAAKpS,KAAM,KAAM,MA2DrB,SAASoS,GAAKtS,EAAQyC,EAAIoC,GACxB,GAAIpC,EAAI,OAAOzC,EAAOoD,KAAK,QAASX,GAOpC,GALY,MAARoC,GACF7E,EAAO4C,KAAKiC,GAIV7E,EAAO0I,eAAe5J,OAAQ,MAAM,IAAI2E,MAAM,8CAElD,GAAIzD,EAAO4R,gBAAgBC,aAAc,MAAM,IAAIpO,MAAM,kDAEzD,OAAOzD,EAAO4C,KAAK,MA7IrBxD,GAAKG,SAAW2R,GAGhB9R,GAAKG,SAASkS,GAAWnT,IAuEzBmT,GAAUnO,UAAUV,KAAO,SAAUN,EAAOT,GAE1C,OADA3B,KAAK0R,gBAAgBI,eAAgB,EAC9B1T,GAAOgF,UAAUV,KAAKR,KAAKlC,KAAMoC,EAAOT,IAajD4P,GAAUnO,UAAU6O,WAAa,SAAU7P,EAAOT,EAAUyC,GAC1D,MAAM,IAAIb,MAAM,oCAGlBgO,GAAUnO,UAAU2J,OAAS,SAAU3K,EAAOT,EAAUyC,GACtD,IAAIqN,EAAKzR,KAAK0R,gBAId,GAHAD,EAAGxF,QAAU7H,EACbqN,EAAGG,WAAaxP,EAChBqP,EAAGM,cAAgBpQ,GACd8P,EAAGE,aAAc,CACpB,IAAIE,EAAK7R,KAAK4B,gBACV6P,EAAGK,eAAiBD,EAAG3Q,cAAgB2Q,EAAGjT,OAASiT,EAAGzR,gBAAeJ,KAAK+B,MAAM8P,EAAGzR,iBAO3FmR,GAAUnO,UAAUrB,MAAQ,SAAU0C,GACpC,IAAIgN,EAAKzR,KAAK0R,gBAEQ,OAAlBD,EAAGG,YAAuBH,EAAGxF,UAAYwF,EAAGE,cAC9CF,EAAGE,cAAe,EAClB3R,KAAKiS,WAAWR,EAAGG,WAAYH,EAAGM,cAAeN,EAAGD,iBAIpDC,EAAGK,eAAgB,GAIvBP,GAAUnO,UAAUnB,SAAW,SAAUkC,EAAKC,GAC5C,IAAIiO,EAASrS,KAEb5B,GAAOgF,UAAUnB,SAASC,KAAKlC,KAAMmE,GAAK,SAAUmO,GAClDlO,EAAGkO,GACHD,EAAOnP,KAAK,iBCzKhBqP,GAAiBC,GAEbjB,GAAYb,GAGZxR,GAAOC,OAAOC,OAAO2R,IAMzB,SAASyB,GAAY3S,GACnB,KAAMG,gBAAgBwS,IAAc,OAAO,IAAIA,GAAY3S,GAE3D0R,GAAUrP,KAAKlC,KAAMH,GARvBX,GAAKG,SAAW2R,GAGhB9R,GAAKG,SAASmT,GAAajB,IAQ3BiB,GAAYpP,UAAU6O,WAAa,SAAU7P,EAAOT,EAAUyC,GAC5DA,EAAG,KAAMhC,mBC7CXlE,EAAUD,EAAiBC,QAAAwS,IAC3B7R,OAAiBX,EACjBA,EAAAC,SAAmBD,EACnBA,EAAAyM,SAAmBoG,GACnB7S,EAAAE,OAAiB4S,GACjB9S,EAAAqT,UAAoBN,GACpB/S,EAAAsU,YAAsBtB,+DCkDtB,SAASuB,GAAUC,EAAM7S,GACxB,OAAMsQ,EAAUtQ,GAGX8S,EAAY9S,EAAS,SACzB6S,EAAKE,IAAM/S,EAAQ+S,KACb9C,EAAU4C,EAAKE,MACb,IAAI5P,UAAW6P,EAAQ,QAAS,MAAOH,EAAKE,MAGhDD,EAAY9S,EAAS,gBACzB6S,EAAKzS,WAAaJ,EAAQI,YACpByP,EAAWgD,EAAKzS,aACd,IAAI+C,UAAW6P,EAAQ,QAAS,aAAcH,EAAKzS,aAGvD0S,EAAY9S,EAAS,cACzB6S,EAAK/Q,SAAW9B,EAAQ8B,UAClBmO,EAAU4C,EAAK/Q,WAAgC,OAAlB+Q,EAAK/Q,UAChC,IAAIqB,UAAW6P,EAAQ,QAAS,WAAYH,EAAK/Q,WAGrDgR,EAAY9S,EAAS,mBACzB6S,EAAKtS,cAAgBP,EAAQO,eACvB0S,EAAeJ,EAAKtS,gBAClB,IAAI4C,UAAW6P,EAAQ,QAAS,gBAAiBH,EAAKtS,gBAG1DuS,EAAY9S,EAAS,eACzB6S,EAAKK,UAAYlT,EAAQkT,WACnBvC,EAAYkC,EAAKK,YACf,IAAI/P,UAAW6P,EAAQ,QAAS,YAAaH,EAAKK,YAGpD,KAhCC,IAAI/P,UAAW6P,EAAQ,QAAShT,QC/BrCN,UC0JJ,SAASyT,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQtT,GACvD,IAAI6S,EACAvO,EACA4C,EACJ,KAAQ/G,gBAAgBgT,IACvB,OAAKjJ,UAAUnL,OAAS,EAChB,IAAIoU,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQtT,GAEpD,IAAImT,GAAoBC,EAAGvS,EAAQwS,EAAQC,GAEnD,IAAMC,EAAsBH,GAC3B,MAAM,IAAIjQ,UAAW6P,EAAQ,QAASI,IAEvC,IAAMI,EAAc3S,GACnB,MAAM,IAAIsC,UAAW6P,EAAQ,QAASnS,IAEvC,IAAM4S,EAAWJ,GAChB,MAAM,IAAIlQ,UAAW6P,EAAQ,QAASK,IAEvC,IAAME,EAAsBD,GAC3B,MAAM,IAAInQ,UAAW6P,EAAQ,QAASM,IAEvC,GAAKF,EAAI,IACRlM,EAAIoM,GAAWF,EAAE,GAAGC,EACfC,GAAUzS,EAAO9B,QAAUmI,EAAI,GAAKA,GAAKrG,EAAO9B,QACpD,MAAM,IAAI2U,WAAYV,EAAQ,UAIhC,GADAH,EAAOpM,EAAMkN,IACRzJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EA+BR,OA3BA5E,GAAO,wEAAyEkU,KAAKC,UAAWhB,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBiB,EAAkB3T,KAAM,cAAc,GAGtC4T,EAA0B5T,KAAM,cAAe0S,EAAKzS,YAGpD2T,EAA0B5T,KAAM,OAAQ0S,EAAKE,KAG7CgB,EAA0B5T,KAAM,aAAc0S,EAAKK,WAAaU,KAAKC,WAGrEE,EAA0B5T,KAAM,UAAWU,GAG3CkT,EAA0B5T,KAAM,KAAMiT,GACtCW,EAA0B5T,KAAM,UAAWkT,GAC3CU,EAA0B5T,KAAM,UAAWmT,GAC3CQ,EAAkB3T,KAAM,OAAQmT,GAGhCQ,EAAkB3T,KAAM,KAAM,GAEvBA,KCjLR,SAASC,GAAYgT,EAAGvS,EAAQwS,EAAQC,EAAQtT,GAC/C,IAAI6S,EACJ,GAAK3I,UAAUnL,OAAS,EAAI,CAE3B,IAAMuR,EADNuC,EAAO7S,GAEN,MAAM,IAAImD,UAAW6P,EAAQ,QAASH,IAEvCA,EAAOpM,EAAMzG,EAAS,QAEtB6S,EAAO,GAGR,OADAA,EAAKzS,YAAa,EACX,IAAI+S,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQT,GCf3D,SAASmB,GAAShU,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAEDiU,EAeP,SAASA,EAAcb,EAAGvS,EAAQwS,EAAQC,GACzC,OAAO,IAAIH,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQT,IFmK5DqB,EAASf,GAAoB7U,EAAAA,QAAAA,UAY7ByV,EAA0BZ,GAAmB5P,UAAW,SApNxD,WAEC,IAAI4Q,EACA7P,EACAgN,EAEJ,IAAKnR,KAAKiU,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA7P,EAAM,KAENnE,KAAKkU,IAAM,EACNlU,KAAKkU,GAAKlU,KAAKmU,GAEnB,OAAOnU,KAAK0C,KAAM,MAEnByO,EAAInR,KAAKoU,QAASpU,KAAKqU,MACvB9U,GAAO,gCAAiCkU,KAAKC,UAAWvC,GAAKnR,KAAKqU,KAAMrU,KAAKkU,IAE7ElU,KAAKqU,MAAQrU,KAAKsU,SACQ,IAArBtU,KAAKuU,cAES,iBADlBpD,EAAInR,KAAKwU,WAAYrD,IAGnBA,EADgB,IAAZnR,KAAKkU,GACLO,EAAetD,GAEfsD,EAAezU,KAAK0U,KAAKvD,GAEnBrO,EAAUqO,GAChBnR,KAAKkU,GAAK,IACd/C,EAAIrS,EAAO2G,OAAQ,CAAEgP,EAAezU,KAAK0U,MAAQvD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB6P,EAAMhU,KAAK0C,KAAMyO,OAsLpByC,EAA0BZ,GAAmB5P,UAAW,WAxKxD,SAAkBuR,GAEjB,IAAIxP,EACJ,OAAKnF,KAAKiU,aAIV9O,EAAOnF,KACPA,KAAKiU,YAAa,EAElBpP,GASA,WACM8P,IACJpV,GAAO,mDAAsD+Q,EAASqE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHxP,EAAKjC,KAAM,QAASyR,IAGrBxP,EAAKjC,KAAM,aApBJlD,QGPT6U,EAAA/U,GAAA,aAAAG,IACA4U,EAAA/U,GAAA,UAAA+T"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e4a000d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var stream = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( stream, 'objectMode', objectMode ); -setReadOnly( stream, 'factory', factory ); - - -// EXPORTS // - -module.exports = stream; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fc09752..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1e2edb0 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From b50d5c5b9748c29166f8fc41f0d19f56530191cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:53:41 +0000 Subject: [PATCH 008/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 0a779a9..fc09752 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From 1e29a0d61a6174fc358ad38b1e7490557c5072f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:56:12 +0000 Subject: [PATCH 009/112] Remove files --- index.d.ts | 305 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2999 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c9730a4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 04bb0c7..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1e2edb0..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 031149cdaa6835b643265d29e60c4c99955b05b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:57:09 +0000 Subject: [PATCH 010/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 --- branches.md | 53 - docs/repl.txt | 155 -- docs/types/test.ts | 189 -- examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 --- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 376 --- test/test.js | 43 - test/test.main.js | 1139 --------- test/test.object_mode.js | 279 --- test/test.validate.js | 241 -- 47 files changed, 2724 insertions(+), 6588 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 f7d4d5f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:14:49.706Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b0ec775 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0adf4ff --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e4a000d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var stream = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( stream, 'objectMode', objectMode ); -setReadOnly( stream, 'factory', factory ); - - -// EXPORTS // - -module.exports = stream; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fc09752..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ec6d998 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 03b95854823aeb724d1fbbbf58049fe7bbcdf1e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:32:30 +0000 Subject: [PATCH 011/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 0a779a9..fc09752 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From aac216e71434b1bd60132d53039570be08eb1969 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:41:16 +0000 Subject: [PATCH 012/112] Remove files --- index.d.ts | 305 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2999 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b0ec775..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0adf4ff..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ec6d998..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 65fe7a84499ae226d37a10e1f56c9d86ecd3c289 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:42:08 +0000 Subject: [PATCH 013/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 --- branches.md | 53 - docs/repl.txt | 155 -- docs/types/test.ts | 189 -- examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 --- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 376 --- test/test.js | 43 - test/test.main.js | 1139 --------- test/test.object_mode.js | 279 --- test/test.validate.js | 241 -- 47 files changed, 2724 insertions(+), 6604 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 c47931f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:12:46.543Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b0ec775 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0adf4ff --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e4a000d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var stream = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( stream, 'objectMode', objectMode ); -setReadOnly( stream, 'factory', factory ); - - -// EXPORTS // - -module.exports = stream; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fc09752..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f0343ba --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From cbc7117ba55f455cf56a9cdb642398d0a5aaed7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 03:56:00 +0000 Subject: [PATCH 014/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 0a779a9..fc09752 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From 4f6fbbb983d1eaa0f549d5c2b12397a917a3f958 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 15:15:20 +0000 Subject: [PATCH 015/112] Remove files --- index.d.ts | 305 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2999 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b0ec775..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0adf4ff..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport stream from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( stream, 'objectMode', objectMode );\nsetReadOnly( stream, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default stream;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":";;khIAyBIA,EAAMC,QAAQ,wBAGlBC,OAAOC,QAAUC,GAGjB,IAIIC,EAJAC,EAAUL,QAAQ,WAOtBG,GAASG,cAAgBA,GAGhBN,QAAQ,UAAUO,aAE3B,IAAIC,EAAkB,SAAUC,EAASC,GACvC,OAAOD,EAAQE,UAAUD,GAAME,QAK7BC,EAASb,QAAQ,6BAKjBc,EAASd,QAAQ,eAAec,OAChCC,EAAgBC,EAAOC,YAAc,aAWzC,IAAIC,EAAOC,OAAOC,OAAOpB,QAAQ,iBACjCkB,EAAKG,SAAWrB,QAAQ,YAIxB,IAAIsB,GAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,IAAaA,GAAUE,SACjBF,GAAUE,SAAS,UAEnB,aAIV,IAEIC,GAFAC,GAAa1B,QAAQ,iCACrB2B,GAAc3B,QAAQ,8BAG1BkB,EAAKG,SAASlB,GAAUU,GAExB,IAAIe,GAAe,CAAC,QAAS,QAAS,UAAW,QAAS,UAc1D,SAAStB,GAAcuB,EAASC,GAG9BD,EAAUA,GAAW,GAOrB,IAAIE,EAAWD,aATf1B,EAASA,GAAUJ,QAAQ,qBAa3BgC,KAAKC,aAAeJ,EAAQI,WAExBF,IAAUC,KAAKC,WAAaD,KAAKC,cAAgBJ,EAAQK,oBAI7D,IAAIC,EAAMN,EAAQO,cACdC,EAAcR,EAAQS,sBACtBC,EAAaP,KAAKC,WAAa,GAAK,MAElBD,KAAKI,cAAvBD,GAAe,IAARA,EAAgCA,EAAaJ,IAAaM,GAA+B,IAAhBA,GAAyCA,EAAsCE,EAGnKP,KAAKI,cAAgBI,KAAKC,MAAMT,KAAKI,eAKrCJ,KAAKU,OAAS,IAAIhB,GAClBM,KAAKpB,OAAS,EACdoB,KAAKW,MAAQ,KACbX,KAAKY,WAAa,EAClBZ,KAAKa,QAAU,KACfb,KAAKc,OAAQ,EACbd,KAAKe,YAAa,EAClBf,KAAKgB,SAAU,EAMfhB,KAAKiB,MAAO,EAIZjB,KAAKkB,cAAe,EACpBlB,KAAKmB,iBAAkB,EACvBnB,KAAKoB,mBAAoB,EACzBpB,KAAKqB,iBAAkB,EAGvBrB,KAAKsB,WAAY,EAKjBtB,KAAKuB,gBAAkB1B,EAAQ0B,iBAAmB,OAGlDvB,KAAKwB,WAAa,EAGlBxB,KAAKyB,aAAc,EAEnBzB,KAAK0B,QAAU,KACf1B,KAAK2B,SAAW,KACZ9B,EAAQ8B,WACLlC,KAAeA,GAAgBzB,QAAQ,mBAAmByB,eAC/DO,KAAK0B,QAAU,IAAIjC,GAAcI,EAAQ8B,UACzC3B,KAAK2B,SAAW9B,EAAQ8B,UAI5B,SAASxD,GAAS0B,GAGhB,GAFAzB,EAASA,GAAUJ,QAAQ,sBAErBgC,gBAAgB7B,IAAW,OAAO,IAAIA,GAAS0B,GAErDG,KAAK4B,eAAiB,IAAItD,GAAcuB,EAASG,MAGjDA,KAAK6B,UAAW,EAEZhC,IAC0B,mBAAjBA,EAAQiC,OAAqB9B,KAAK+B,MAAQlC,EAAQiC,MAE9B,mBAApBjC,EAAQmC,UAAwBhC,KAAKiC,SAAWpC,EAAQmC,UAGrEnD,EAAOqD,KAAKlC,MA2Dd,SAASmC,GAAiBrC,EAAQsC,EAAOT,EAAUU,EAAYC,GAC7D,IAKMC,EALFC,EAAQ1C,EAAO8B,eACL,OAAVQ,GACFI,EAAMxB,SAAU,EA0NpB,SAAoBlB,EAAQ0C,GAC1B,GAAIA,EAAM1B,MAAO,OACjB,GAAI0B,EAAMd,QAAS,CACjB,IAAIU,EAAQI,EAAMd,QAAQe,MACtBL,GAASA,EAAMxD,SACjB4D,EAAM9B,OAAOgC,KAAKN,GAClBI,EAAM5D,QAAU4D,EAAMvC,WAAa,EAAImC,EAAMxD,QAGjD4D,EAAM1B,OAAQ,EAGd6B,GAAa7C,GArOX8C,CAAW9C,EAAQ0C,KAGdF,IAAgBC,EA2CzB,SAAsBC,EAAOJ,GAC3B,IAAIG,EApPiBM,EAqPFT,EApPZtD,EAAOgE,SAASD,IAAQA,aAAe9D,GAoPA,iBAAVqD,QAAgCW,IAAVX,GAAwBI,EAAMvC,aACtFsC,EAAK,IAAIS,UAAU,oCAtPvB,IAAuBH,EAwPrB,OAAON,EAhDqBU,CAAaT,EAAOJ,IAC1CG,EACFzC,EAAOoD,KAAK,QAASX,GACZC,EAAMvC,YAAcmC,GAASA,EAAMxD,OAAS,GAChC,iBAAVwD,GAAuBI,EAAMvC,YAAcd,OAAOgE,eAAef,KAAWtD,EAAOsE,YAC5FhB,EAhNR,SAA6BA,GAC3B,OAAOtD,EAAOuE,KAAKjB,GA+MLkB,CAAoBlB,IAG1BC,EACEG,EAAMzB,WAAYjB,EAAOoD,KAAK,QAAS,IAAIK,MAAM,qCAA0CC,GAAS1D,EAAQ0C,EAAOJ,GAAO,GACrHI,EAAM1B,MACfhB,EAAOoD,KAAK,QAAS,IAAIK,MAAM,6BAE/Bf,EAAMxB,SAAU,EACZwB,EAAMd,UAAYC,GACpBS,EAAQI,EAAMd,QAAQ+B,MAAMrB,GACxBI,EAAMvC,YAA+B,IAAjBmC,EAAMxD,OAAc4E,GAAS1D,EAAQ0C,EAAOJ,GAAO,GAAYsB,GAAc5D,EAAQ0C,IAE7GgB,GAAS1D,EAAQ0C,EAAOJ,GAAO,KAGzBC,IACVG,EAAMxB,SAAU,IAIpB,OAgCF,SAAsBwB,GACpB,OAAQA,EAAM1B,QAAU0B,EAAMtB,cAAgBsB,EAAM5D,OAAS4D,EAAMpC,eAAkC,IAAjBoC,EAAM5D,QAjCnF+E,CAAanB,GAGtB,SAASgB,GAAS1D,EAAQ0C,EAAOJ,EAAOC,GAClCG,EAAM3B,SAA4B,IAAjB2B,EAAM5D,SAAiB4D,EAAMvB,MAChDnB,EAAOoD,KAAK,OAAQd,GACpBtC,EAAOgC,KAAK,KAGZU,EAAM5D,QAAU4D,EAAMvC,WAAa,EAAImC,EAAMxD,OACzCyD,EAAYG,EAAM9B,OAAOkD,QAAQxB,GAAYI,EAAM9B,OAAOgC,KAAKN,GAE/DI,EAAMtB,cAAcyB,GAAa7C,IAEvC4D,GAAc5D,EAAQ0C,GAvGxBrD,OAAO0E,eAAe1F,GAASiF,UAAW,YAAa,CACrDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAK4B,gBAGF5B,KAAK4B,eAAeN,WAE7ByC,IAAK,SAAUC,GAGRhE,KAAK4B,iBAMV5B,KAAK4B,eAAeN,UAAY0C,MAIpC7F,GAASiF,UAAUpB,QAAUrC,GAAYqC,QACzC7D,GAASiF,UAAUa,WAAatE,GAAYuE,UAC5C/F,GAASiF,UAAUnB,SAAW,SAAUkC,EAAKC,GAC3CpE,KAAK0C,KAAK,MACV0B,EAAGD,IAOLhG,GAASiF,UAAUV,KAAO,SAAUN,EAAOT,GACzC,IACIW,EADAE,EAAQxC,KAAK4B,eAgBjB,OAbKY,EAAMvC,WAUTqC,GAAiB,EATI,iBAAVF,KACTT,EAAWA,GAAYa,EAAMjB,mBACZiB,EAAMb,WACrBS,EAAQtD,EAAOuE,KAAKjB,EAAOT,GAC3BA,EAAW,IAEbW,GAAiB,GAMdH,GAAiBnC,KAAMoC,EAAOT,GAAU,EAAOW,IAIxDnE,GAASiF,UAAUQ,QAAU,SAAUxB,GACrC,OAAOD,GAAiBnC,KAAMoC,EAAO,MAAM,GAAM,IAwEnDjE,GAASiF,UAAUiB,SAAW,WAC5B,OAAuC,IAAhCrE,KAAK4B,eAAef,SAI7B1C,GAASiF,UAAUkB,YAAc,SAAUC,GAIzC,OAHK9E,KAAeA,GAAgBzB,QAAQ,mBAAmByB,eAC/DO,KAAK4B,eAAeF,QAAU,IAAIjC,GAAc8E,GAChDvE,KAAK4B,eAAeD,SAAW4C,EACxBvE,MAwBT,SAASwE,GAAcC,EAAGjC,GACxB,OAAIiC,GAAK,GAAsB,IAAjBjC,EAAM5D,QAAgB4D,EAAM1B,MAAc,EACpD0B,EAAMvC,WAAmB,EACzBwE,GAAMA,EAEJjC,EAAM3B,SAAW2B,EAAM5D,OAAe4D,EAAM9B,OAAOgE,KAAKC,KAAK/F,OAAmB4D,EAAM5D,QAGxF6F,EAAIjC,EAAMpC,gBAAeoC,EAAMpC,cA3BrC,SAAiCqE,GAc/B,OAbIA,GAFQ,QAGVA,EAHU,SAOVA,IACAA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,EACXA,GAAKA,IAAM,GACXA,KAEKA,EAa4CG,CAAwBH,IACvEA,GAAKjC,EAAM5D,OAAe6F,EAEzBjC,EAAM1B,MAIJ0B,EAAM5D,QAHX4D,EAAMtB,cAAe,EACd,IA4HX,SAASyB,GAAa7C,GACpB,IAAI0C,EAAQ1C,EAAO8B,eACnBY,EAAMtB,cAAe,EAChBsB,EAAMrB,kBACT5B,GAAM,eAAgBiD,EAAM3B,SAC5B2B,EAAMrB,iBAAkB,EACpBqB,EAAMvB,KAAMlD,EAAI8G,SAASC,GAAehF,GAAagF,GAAchF,IAI3E,SAASgF,GAAchF,GACrBP,GAAM,iBACNO,EAAOoD,KAAK,YACZ6B,GAAKjF,GASP,SAAS4D,GAAc5D,EAAQ0C,GACxBA,EAAMf,cACTe,EAAMf,aAAc,EACpB1D,EAAI8G,SAASG,GAAgBlF,EAAQ0C,IAIzC,SAASwC,GAAelF,EAAQ0C,GAE9B,IADA,IAAIyC,EAAMzC,EAAM5D,QACR4D,EAAMxB,UAAYwB,EAAM3B,UAAY2B,EAAM1B,OAAS0B,EAAM5D,OAAS4D,EAAMpC,gBAC9Eb,GAAM,wBACNO,EAAOgC,KAAK,GACRmD,IAAQzC,EAAM5D,SAELqG,EAAMzC,EAAM5D,OAE3B4D,EAAMf,aAAc,EAyOtB,SAASyD,GAAiBC,GACxB5F,GAAM,4BACN4F,EAAKrD,KAAK,GAsBZ,SAASsD,GAAQtF,EAAQ0C,GAClBA,EAAMxB,UACTzB,GAAM,iBACNO,EAAOgC,KAAK,IAGdU,EAAMnB,iBAAkB,EACxBmB,EAAMhB,WAAa,EACnB1B,EAAOoD,KAAK,UACZ6B,GAAKjF,GACD0C,EAAM3B,UAAY2B,EAAMxB,SAASlB,EAAOgC,KAAK,GAanD,SAASiD,GAAKjF,GACZ,IAAI0C,EAAQ1C,EAAO8B,eAEnB,IADArC,GAAM,OAAQiD,EAAM3B,SACb2B,EAAM3B,SAA6B,OAAlBf,EAAOgC,UAmFjC,SAASuD,GAASZ,EAAGjC,GAEnB,OAAqB,IAAjBA,EAAM5D,OAAqB,MAG3B4D,EAAMvC,WAAYqF,EAAM9C,EAAM9B,OAAO6E,SAAkBd,GAAKA,GAAKjC,EAAM5D,QAEtD0G,EAAf9C,EAAMd,QAAec,EAAM9B,OAAO8E,KAAK,IAAqC,IAAxBhD,EAAM9B,OAAO9B,OAAoB4D,EAAM9B,OAAOgE,KAAKC,KAAgBnC,EAAM9B,OAAO+E,OAAOjD,EAAM5D,QACrJ4D,EAAM9B,OAAOgF,SAGbJ,EASJ,SAAyBb,EAAGkB,EAAMC,GAChC,IAAIN,EACAb,EAAIkB,EAAKjB,KAAKC,KAAK/F,QAErB0G,EAAMK,EAAKjB,KAAKC,KAAKkB,MAAM,EAAGpB,GAC9BkB,EAAKjB,KAAKC,KAAOgB,EAAKjB,KAAKC,KAAKkB,MAAMpB,IAGtCa,EAFSb,IAAMkB,EAAKjB,KAAKC,KAAK/F,OAExB+G,EAAKJ,QAGLK,EASV,SAA8BnB,EAAGkB,GAC/B,IAAIG,EAAIH,EAAKjB,KACTqB,EAAI,EACJT,EAAMQ,EAAEnB,KACZF,GAAKa,EAAI1G,OACT,KAAOkH,EAAIA,EAAEE,MAAM,CACjB,IAAIC,EAAMH,EAAEnB,KACRuB,EAAKzB,EAAIwB,EAAIrH,OAASqH,EAAIrH,OAAS6F,EAGvC,GAFIyB,IAAOD,EAAIrH,OAAQ0G,GAAOW,EAASX,GAAOW,EAAIJ,MAAM,EAAGpB,GAEjD,KADVA,GAAKyB,GACQ,CACPA,IAAOD,EAAIrH,UACXmH,EACED,EAAEE,KAAML,EAAKjB,KAAOoB,EAAEE,KAAUL,EAAKjB,KAAOiB,EAAKQ,KAAO,OAE5DR,EAAKjB,KAAOoB,EACZA,EAAEnB,KAAOsB,EAAIJ,MAAMK,IAErB,QAEAH,EAGJ,OADAJ,EAAK/G,QAAUmH,EACRT,EAhCcc,CAAqB3B,EAAGkB,GAsC/C,SAAwBlB,EAAGkB,GACzB,IAAIL,EAAMxG,EAAOuH,YAAY5B,GACzBqB,EAAIH,EAAKjB,KACTqB,EAAI,EACRD,EAAEnB,KAAK2B,KAAKhB,GACZb,GAAKqB,EAAEnB,KAAK/F,OACZ,KAAOkH,EAAIA,EAAEE,MAAM,CACjB,IAAIO,EAAMT,EAAEnB,KACRuB,EAAKzB,EAAI8B,EAAI3H,OAAS2H,EAAI3H,OAAS6F,EAGvC,GAFA8B,EAAID,KAAKhB,EAAKA,EAAI1G,OAAS6F,EAAG,EAAGyB,GAEvB,KADVzB,GAAKyB,GACQ,CACPA,IAAOK,EAAI3H,UACXmH,EACED,EAAEE,KAAML,EAAKjB,KAAOoB,EAAEE,KAAUL,EAAKjB,KAAOiB,EAAKQ,KAAO,OAE5DR,EAAKjB,KAAOoB,EACZA,EAAEnB,KAAO4B,EAAIV,MAAMK,IAErB,QAEAH,EAGJ,OADAJ,EAAK/G,QAAUmH,EACRT,EA9D8CkB,CAAe/B,EAAGkB,GAEvE,OAAOL,EAtBCmB,CAAgBhC,EAAGjC,EAAM9B,OAAQ8B,EAAMd,SAGxC4D,GAVP,IAAIA,EA4FN,SAASoB,GAAY5G,GACnB,IAAI0C,EAAQ1C,EAAO8B,eAInB,GAAIY,EAAM5D,OAAS,EAAG,MAAM,IAAI2E,MAAM,8CAEjCf,EAAMzB,aACTyB,EAAM1B,OAAQ,EACd/C,EAAI8G,SAAS8B,GAAenE,EAAO1C,IAIvC,SAAS6G,GAAcnE,EAAO1C,GAEvB0C,EAAMzB,YAA+B,IAAjByB,EAAM5D,SAC7B4D,EAAMzB,YAAa,EACnBjB,EAAO+B,UAAW,EAClB/B,EAAOoD,KAAK,QAIhB,SAAS0D,GAAQC,EAAIC,GACnB,IAAK,IAAIC,EAAI,EAAGC,EAAIH,EAAGjI,OAAQmI,EAAIC,EAAGD,IACpC,GAAIF,EAAGE,KAAOD,EAAG,OAAOC,EAE1B,OAAQ,EApoBV5I,GAASiF,UAAUtB,KAAO,SAAU2C,GAClClF,GAAM,OAAQkF,GACdA,EAAIwC,SAASxC,EAAG,IAChB,IAAIjC,EAAQxC,KAAK4B,eACbsF,EAAQzC,EAOZ,GALU,IAANA,IAASjC,EAAMrB,iBAAkB,GAK3B,IAANsD,GAAWjC,EAAMtB,eAAiBsB,EAAM5D,QAAU4D,EAAMpC,eAAiBoC,EAAM1B,OAGjF,OAFAvB,GAAM,qBAAsBiD,EAAM5D,OAAQ4D,EAAM1B,OAC3B,IAAjB0B,EAAM5D,QAAgB4D,EAAM1B,MAAO4F,GAAY1G,MAAW2C,GAAa3C,MACpE,KAMT,GAAU,KAHVyE,EAAID,GAAcC,EAAGjC,KAGNA,EAAM1B,MAEnB,OADqB,IAAjB0B,EAAM5D,QAAc8H,GAAY1G,MAC7B,KA0BT,IA4BIsF,EA5BA6B,EAAS3E,EAAMtB,aAiDnB,OAhDA3B,GAAM,gBAAiB4H,IAGF,IAAjB3E,EAAM5D,QAAgB4D,EAAM5D,OAAS6F,EAAIjC,EAAMpC,gBAEjDb,GAAM,6BADN4H,GAAS,GAMP3E,EAAM1B,OAAS0B,EAAMxB,QAEvBzB,GAAM,mBADN4H,GAAS,GAEAA,IACT5H,GAAM,WACNiD,EAAMxB,SAAU,EAChBwB,EAAMvB,MAAO,EAEQ,IAAjBuB,EAAM5D,SAAc4D,EAAMtB,cAAe,GAE7ClB,KAAK+B,MAAMS,EAAMpC,eACjBoC,EAAMvB,MAAO,EAGRuB,EAAMxB,UAASyD,EAAID,GAAc0C,EAAO1E,KAMnC,QAFD8C,EAAPb,EAAI,EAASY,GAASZ,EAAGjC,GAAkB,OAG7CA,EAAMtB,cAAe,EACrBuD,EAAI,GAEJjC,EAAM5D,QAAU6F,EAGG,IAAjBjC,EAAM5D,SAGH4D,EAAM1B,QAAO0B,EAAMtB,cAAe,GAGnCgG,IAAUzC,GAAKjC,EAAM1B,OAAO4F,GAAY1G,OAGlC,OAARsF,GAActF,KAAKkD,KAAK,OAAQoC,GAE7BA,GAkETnH,GAASiF,UAAUrB,MAAQ,SAAU0C,GACnCzE,KAAKkD,KAAK,QAAS,IAAIK,MAAM,gCAG/BpF,GAASiF,UAAUgE,KAAO,SAAUC,EAAMC,GACxC,IAAIC,EAAMvH,KACNwC,EAAQxC,KAAK4B,eAEjB,OAAQY,EAAM5B,YACZ,KAAK,EACH4B,EAAM7B,MAAQ0G,EACd,MACF,KAAK,EACH7E,EAAM7B,MAAQ,CAAC6B,EAAM7B,MAAO0G,GAC5B,MACF,QACE7E,EAAM7B,MAAM+B,KAAK2E,GAGrB7E,EAAM5B,YAAc,EACpBrB,GAAM,wBAAyBiD,EAAM5B,WAAY0G,GAEjD,IAEIE,IAFUF,IAA6B,IAAjBA,EAAS7E,MAAkB4E,IAASI,EAAQC,QAAUL,IAASI,EAAQE,OAE7EC,EAAQC,EAI5B,SAASC,EAASjG,EAAUkG,GAC1BxI,GAAM,YACFsC,IAAa0F,GACXQ,IAAwC,IAA1BA,EAAWC,aAC3BD,EAAWC,YAAa,EAoB5BzI,GAAM,WAEN8H,EAAKY,eAAe,QAASC,GAC7Bb,EAAKY,eAAe,SAAUE,GAC9Bd,EAAKY,eAAe,QAASG,GAC7Bf,EAAKY,eAAe,QAASI,GAC7BhB,EAAKY,eAAe,SAAUH,GAC9BP,EAAIU,eAAe,MAAOL,GAC1BL,EAAIU,eAAe,MAAOJ,GAC1BN,EAAIU,eAAe,OAAQK,GAE3BC,GAAY,GAOR/F,EAAMhB,YAAgB6F,EAAKmB,iBAAkBnB,EAAKmB,eAAeC,WAAYL,KAhCnF,SAASR,IACPrI,GAAM,SACN8H,EAAK5E,MAfHD,EAAMzB,WAAYhD,EAAI8G,SAAS2C,GAAYD,EAAImB,KAAK,MAAOlB,GAE/DH,EAAKsB,GAAG,SAAUb,GAoBlB,IAAIM,EA4FN,SAAqBb,GACnB,OAAO,WACL,IAAI/E,EAAQ+E,EAAI3F,eAChBrC,GAAM,cAAeiD,EAAMhB,YACvBgB,EAAMhB,YAAYgB,EAAMhB,aACH,IAArBgB,EAAMhB,YAAoBhD,EAAgB+I,EAAK,UACjD/E,EAAM3B,SAAU,EAChBkE,GAAKwC,KAnGKqB,CAAYrB,GAC1BF,EAAKsB,GAAG,QAASP,GAEjB,IAAIG,GAAY,EA2BhB,IAAIM,GAAsB,EAE1B,SAASP,EAAOlG,GACd7C,GAAM,UACNsJ,GAAsB,GAElB,IADMxB,EAAK5D,MAAMrB,IACCyG,KAKM,IAArBrG,EAAM5B,YAAoB4B,EAAM7B,QAAU0G,GAAQ7E,EAAM5B,WAAa,IAAqC,IAAhCgG,GAAQpE,EAAM7B,MAAO0G,MAAkBkB,IACpHhJ,GAAM,8BAA+BgI,EAAI3F,eAAeJ,YACxD+F,EAAI3F,eAAeJ,aACnBqH,GAAsB,GAExBtB,EAAIuB,SAMR,SAAST,EAAQ9F,GACfhD,GAAM,UAAWgD,GACjBsF,IACAR,EAAKY,eAAe,QAASI,GACU,IAAnC7J,EAAgB6I,EAAM,UAAgBA,EAAKnE,KAAK,QAASX,GAO/D,SAAS2F,IACPb,EAAKY,eAAe,SAAUE,GAC9BN,IAGF,SAASM,IACP5I,GAAM,YACN8H,EAAKY,eAAe,QAASC,GAC7BL,IAIF,SAASA,IACPtI,GAAM,UACNgI,EAAIM,OAAOR,GAYb,OA1DAE,EAAIoB,GAAG,OAAQL,GA9gBjB,SAAyB7J,EAASsK,EAAOC,GAGvC,GAAuC,mBAA5BvK,EAAQwK,gBAAgC,OAAOxK,EAAQwK,gBAAgBF,EAAOC,GAMpFvK,EAAQyK,SAAYzK,EAAQyK,QAAQH,GAAuC1K,EAAQI,EAAQyK,QAAQH,IAAStK,EAAQyK,QAAQH,GAAOnF,QAAQoF,GAASvK,EAAQyK,QAAQH,GAAS,CAACC,EAAIvK,EAAQyK,QAAQH,IAAtJtK,EAAQkK,GAAGI,EAAOC,GAkiBnEC,CAAgB5B,EAAM,QAASgB,GAO/BhB,EAAKqB,KAAK,QAASR,GAMnBb,EAAKqB,KAAK,SAAUP,GAQpBd,EAAKnE,KAAK,OAAQqE,GAGb/E,EAAM3B,UACTtB,GAAM,eACNgI,EAAI4B,UAGC9B,GAeTlJ,GAASiF,UAAUyE,OAAS,SAAUR,GACpC,IAAI7E,EAAQxC,KAAK4B,eACbmG,EAAa,CAAEC,YAAY,GAG/B,GAAyB,IAArBxF,EAAM5B,WAAkB,OAAOZ,KAGnC,GAAyB,IAArBwC,EAAM5B,WAER,OAAIyG,GAAQA,IAAS7E,EAAM7B,QAEtB0G,IAAMA,EAAO7E,EAAM7B,OAGxB6B,EAAM7B,MAAQ,KACd6B,EAAM5B,WAAa,EACnB4B,EAAM3B,SAAU,EACZwG,GAAMA,EAAKnE,KAAK,SAAUlD,KAAM+H,IARK/H,KAc3C,IAAKqH,EAAM,CAET,IAAI+B,EAAQ5G,EAAM7B,MACdsE,EAAMzC,EAAM5B,WAChB4B,EAAM7B,MAAQ,KACd6B,EAAM5B,WAAa,EACnB4B,EAAM3B,SAAU,EAEhB,IAAK,IAAIkG,EAAI,EAAGA,EAAI9B,EAAK8B,IACvBqC,EAAMrC,GAAG7D,KAAK,SAAUlD,KAAM+H,GAC/B,OAAO/H,KAIV,IAAIqJ,EAAQzC,GAAQpE,EAAM7B,MAAO0G,GACjC,OAAe,IAAXgC,IAEJ7G,EAAM7B,MAAM2I,OAAOD,EAAO,GAC1B7G,EAAM5B,YAAc,EACK,IAArB4B,EAAM5B,aAAkB4B,EAAM7B,MAAQ6B,EAAM7B,MAAM,IAEtD0G,EAAKnE,KAAK,SAAUlD,KAAM+H,IAND/H,MAa3B7B,GAASiF,UAAUuF,GAAK,SAAUY,EAAIP,GACpC,IAAIQ,EAAM3K,EAAOuE,UAAUuF,GAAGzG,KAAKlC,KAAMuJ,EAAIP,GAE7C,GAAW,SAAPO,GAEkC,IAAhCvJ,KAAK4B,eAAef,SAAmBb,KAAKmJ,cAC3C,GAAW,aAAPI,EAAmB,CAC5B,IAAI/G,EAAQxC,KAAK4B,eACZY,EAAMzB,YAAeyB,EAAMpB,oBAC9BoB,EAAMpB,kBAAoBoB,EAAMtB,cAAe,EAC/CsB,EAAMrB,iBAAkB,EACnBqB,EAAMxB,QAEAwB,EAAM5D,QACf+D,GAAa3C,MAFbjC,EAAI8G,SAASK,GAAkBlF,OAOrC,OAAOwJ,GAETrL,GAASiF,UAAUqG,YAActL,GAASiF,UAAUuF,GASpDxK,GAASiF,UAAU+F,OAAS,WAC1B,IAAI3G,EAAQxC,KAAK4B,eAMjB,OALKY,EAAM3B,UACTtB,GAAM,UACNiD,EAAM3B,SAAU,EAMpB,SAAgBf,EAAQ0C,GACjBA,EAAMnB,kBACTmB,EAAMnB,iBAAkB,EACxBtD,EAAI8G,SAASO,GAAStF,EAAQ0C,IAR9B2G,CAAOnJ,KAAMwC,IAERxC,MAuBT7B,GAASiF,UAAU0F,MAAQ,WAOzB,OANAvJ,GAAM,wBAAyBS,KAAK4B,eAAef,UAC/C,IAAUb,KAAK4B,eAAef,UAChCtB,GAAM,SACNS,KAAK4B,eAAef,SAAU,EAC9Bb,KAAKkD,KAAK,UAELlD,MAYT7B,GAASiF,UAAUsG,KAAO,SAAU5J,GAClC,IAAI6J,EAAQ3J,KAERwC,EAAQxC,KAAK4B,eACbgI,GAAS,EA4Bb,IAAK,IAAI7C,KA1BTjH,EAAO6I,GAAG,OAAO,WAEf,GADApJ,GAAM,eACFiD,EAAMd,UAAYc,EAAM1B,MAAO,CACjC,IAAIsB,EAAQI,EAAMd,QAAQe,MACtBL,GAASA,EAAMxD,QAAQ+K,EAAMjH,KAAKN,GAGxCuH,EAAMjH,KAAK,SAGb5C,EAAO6I,GAAG,QAAQ,SAAUvG,IAC1B7C,GAAM,gBACFiD,EAAMd,UAASU,EAAQI,EAAMd,QAAQ+B,MAAMrB,IAG3CI,EAAMvC,YAAe,MAAAmC,KAAyDI,EAAMvC,YAAgBmC,GAAUA,EAAMxD,UAE9G+K,EAAMjH,KAAKN,KAEnBwH,GAAS,EACT9J,EAAOgJ,aAMGhJ,OACIiD,IAAZ/C,KAAK+G,IAAyC,mBAAdjH,EAAOiH,KACzC/G,KAAK+G,GAAK,SAAU8C,GAClB,OAAO,WACL,OAAO/J,EAAO+J,GAAQC,MAAMhK,EAAQiK,YAF9B,CAIRhD,IAKN,IAAK,IAAItC,EAAI,EAAGA,EAAI7E,GAAahB,OAAQ6F,IACvC3E,EAAO6I,GAAG/I,GAAa6E,GAAIzE,KAAKkD,KAAK8G,KAAKhK,KAAMJ,GAAa6E,KAa/D,OARAzE,KAAK+B,MAAQ,SAAU0C,GACrBlF,GAAM,gBAAiBkF,GACnBmF,IACFA,GAAS,EACT9J,EAAOqJ,WAIJnJ,MAGTb,OAAO0E,eAAe1F,GAASiF,UAAW,wBAAyB,CAIjE6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAK4B,eAAexB,iBAK/BjC,GAAS+L,UAAY7E,6CC51BjBtH,GAAMC,QAAQ,wBAelB,SAASmM,GAAc3H,GACrB,IAAImH,EAAQ3J,KAEZA,KAAKgG,KAAO,KACZhG,KAAKoK,MAAQ,KACbpK,KAAKqK,OAAS,YAolBhB,SAAwBC,EAAS9H,EAAO2B,GACtC,IAAIiG,EAAQE,EAAQF,MACpBE,EAAQF,MAAQ,KAChB,KAAOA,GAAO,CACZ,IAAIhG,EAAKgG,EAAMG,SACf/H,EAAMgI,YACNpG,EAAGD,GACHiG,EAAQA,EAAMpE,KAEZxD,EAAMiI,mBACRjI,EAAMiI,mBAAmBzE,KAAOsE,EAEhC9H,EAAMiI,mBAAqBH,EA/lB3BI,CAAef,EAAOnH,IAlB1BvE,OAAOC,QAAUyM,GAwBjB,IAIIvM,GAJAwM,IAAcnD,EAAQoD,SAAW,CAAC,QAAS,SAASjE,QAAQa,EAAQqD,QAAQjF,MAAM,EAAG,KAAO,EAAIkF,aAAehN,GAAI8G,SAOvH8F,GAASK,cAAgBA,GAGzB,IAAI9L,GAAOC,OAAOC,OAAOpB,QAAQ,iBACjCkB,GAAKG,SAAWrB,QAAQ,YAIxB,IAAIiN,GAAe,CACjBC,UAAWlN,QAAQ,mBAKjBa,GAASb,QAAQ,6BAKjBc,GAASd,QAAQ,eAAec,OAChCC,GAAgBC,EAAOC,YAAc,aAUzC,IA2IIkM,GA3IAxL,GAAc3B,QAAQ,8BAI1B,SAASoN,MAET,SAASJ,GAAcnL,EAASC,GAC9B1B,GAASA,IAAUJ,QAAQ,oBAE3B6B,EAAUA,GAAW,GAOrB,IAAIE,EAAWD,aAAkB1B,GAIjC4B,KAAKC,aAAeJ,EAAQI,WAExBF,IAAUC,KAAKC,WAAaD,KAAKC,cAAgBJ,EAAQwL,oBAK7D,IAAIlL,EAAMN,EAAQO,cACdkL,EAAczL,EAAQ0L,sBACtBhL,EAAaP,KAAKC,WAAa,GAAK,MAElBD,KAAKI,cAAvBD,GAAe,IAARA,EAAgCA,EAAaJ,IAAauL,GAA+B,IAAhBA,GAAyCA,EAAsC/K,EAGnKP,KAAKI,cAAgBI,KAAKC,MAAMT,KAAKI,eAGrCJ,KAAKwL,aAAc,EAGnBxL,KAAKyI,WAAY,EAEjBzI,KAAKyL,QAAS,EAEdzL,KAAKc,OAAQ,EAEbd,KAAK0L,UAAW,EAGhB1L,KAAKsB,WAAY,EAKjB,IAAIqK,GAAqC,IAA1B9L,EAAQ+L,cACvB5L,KAAK4L,eAAiBD,EAKtB3L,KAAKuB,gBAAkB1B,EAAQ0B,iBAAmB,OAKlDvB,KAAKpB,OAAS,EAGdoB,KAAK6L,SAAU,EAGf7L,KAAK8L,OAAS,EAMd9L,KAAKiB,MAAO,EAKZjB,KAAK+L,kBAAmB,EAGxB/L,KAAKgM,QAAU,SAAUzJ,IA4R3B,SAAiBzC,EAAQyC,GACvB,IAAIC,EAAQ1C,EAAO0I,eACfvH,EAAOuB,EAAMvB,KACbmD,EAAK5B,EAAMyJ,QAIf,GAdF,SAA4BzJ,GAC1BA,EAAMqJ,SAAU,EAChBrJ,EAAMyJ,QAAU,KAChBzJ,EAAM5D,QAAU4D,EAAM0J,SACtB1J,EAAM0J,SAAW,EAQjBC,CAAmB3J,GAEfD,GAtCN,SAAsBzC,EAAQ0C,EAAOvB,EAAMsB,EAAI6B,KAC3C5B,EAAMgI,UAEJvJ,GAGFlD,GAAI8G,SAAST,EAAI7B,GAGjBxE,GAAI8G,SAASuH,GAAatM,EAAQ0C,GAClC1C,EAAO0I,eAAe6D,cAAe,EACrCvM,EAAOoD,KAAK,QAASX,KAIrB6B,EAAG7B,GACHzC,EAAO0I,eAAe6D,cAAe,EACrCvM,EAAOoD,KAAK,QAASX,GAGrB6J,GAAYtM,EAAQ0C,IAkBd8J,CAAaxM,EAAQ0C,EAAOvB,EAAMsB,EAAI6B,OAAS,CAErD,IAAIsH,EAAWa,GAAW/J,GAErBkJ,GAAalJ,EAAMsJ,QAAWtJ,EAAMuJ,mBAAoBvJ,EAAMgK,iBACjEC,GAAY3M,EAAQ0C,GAGlBvB,EAEF2J,GAAW8B,GAAY5M,EAAQ0C,EAAOkJ,EAAUtH,GAGhDsI,GAAW5M,EAAQ0C,EAAOkJ,EAAUtH,IA/StC4H,CAAQlM,EAAQyC,IAIlBvC,KAAKiM,QAAU,KAGfjM,KAAKkM,SAAW,EAEhBlM,KAAKwM,gBAAkB,KACvBxM,KAAK2M,oBAAsB,KAI3B3M,KAAKwK,UAAY,EAIjBxK,KAAK4M,aAAc,EAGnB5M,KAAKqM,cAAe,EAGpBrM,KAAK6M,qBAAuB,EAI5B7M,KAAKyK,mBAAqB,IAAIN,GAAcnK,MA0C9C,SAAS2K,GAAS9K,GAUhB,GATAzB,GAASA,IAAUJ,QAAQ,sBAStBmN,GAAgBjJ,KAAKyI,GAAU3K,OAAWA,gBAAgB5B,IAC7D,OAAO,IAAIuM,GAAS9K,GAGtBG,KAAKwI,eAAiB,IAAIwC,GAAcnL,EAASG,MAGjDA,KAAK8M,UAAW,EAEZjN,IAC2B,mBAAlBA,EAAQ4D,QAAsBzD,KAAK+M,OAASlN,EAAQ4D,OAEjC,mBAAnB5D,EAAQmN,SAAuBhN,KAAKiN,QAAUpN,EAAQmN,QAElC,mBAApBnN,EAAQmC,UAAwBhC,KAAKiC,SAAWpC,EAAQmC,SAEtC,mBAAlBnC,EAAQqN,QAAsBlN,KAAKmN,OAAStN,EAAQqN,QAGjErO,GAAOqD,KAAKlC,MAgJd,SAASoN,GAAQtN,EAAQ0C,EAAOwK,EAAQ/H,EAAK7C,EAAOT,EAAUyC,GAC5D5B,EAAM0J,SAAWjH,EACjBzC,EAAMyJ,QAAU7H,EAChB5B,EAAMqJ,SAAU,EAChBrJ,EAAMvB,MAAO,EACT+L,EAAQlN,EAAOmN,QAAQ7K,EAAOI,EAAMwJ,SAAclM,EAAOiN,OAAO3K,EAAOT,EAAUa,EAAMwJ,SAC3FxJ,EAAMvB,MAAO,EA2Df,SAASyL,GAAW5M,EAAQ0C,EAAOkJ,EAAUtH,GACtCsH,GASP,SAAsB5L,EAAQ0C,GACP,IAAjBA,EAAM5D,QAAgB4D,EAAMiG,YAC9BjG,EAAMiG,WAAY,EAClB3I,EAAOoD,KAAK,UAZCmK,CAAavN,EAAQ0C,GACpCA,EAAMgI,YACNpG,IACAgI,GAAYtM,EAAQ0C,GActB,SAASiK,GAAY3M,EAAQ0C,GAC3BA,EAAMuJ,kBAAmB,EACzB,IAAI3B,EAAQ5H,EAAMgK,gBAElB,GAAI1M,EAAOmN,SAAW7C,GAASA,EAAMpE,KAAM,CAEzC,IAAIgB,EAAIxE,EAAMqK,qBACVnM,EAAS,IAAI4M,MAAMtG,GACnBuG,EAAS/K,EAAMiI,mBACnB8C,EAAOnD,MAAQA,EAIf,IAFA,IAAIoD,EAAQ,EACRC,GAAa,EACVrD,GACL1J,EAAO8M,GAASpD,EACXA,EAAMsD,QAAOD,GAAa,GAC/BrD,EAAQA,EAAMpE,KACdwH,GAAS,EAEX9M,EAAO+M,WAAaA,EAEpBL,GAAQtN,EAAQ0C,GAAO,EAAMA,EAAM5D,OAAQ8B,EAAQ,GAAI6M,EAAOlD,QAI9D7H,EAAMgI,YACNhI,EAAMmK,oBAAsB,KACxBY,EAAOvH,MACTxD,EAAMiI,mBAAqB8C,EAAOvH,KAClCuH,EAAOvH,KAAO,MAEdxD,EAAMiI,mBAAqB,IAAIN,GAAc3H,GAE/CA,EAAMqK,qBAAuB,MACxB,CAEL,KAAOzC,GAAO,CACZ,IAAIhI,EAAQgI,EAAMhI,MACdT,EAAWyI,EAAMzI,SACjByC,EAAKgG,EAAMG,SAUf,GAPA6C,GAAQtN,EAAQ0C,GAAO,EAFbA,EAAMvC,WAAa,EAAImC,EAAMxD,OAEJwD,EAAOT,EAAUyC,GACpDgG,EAAQA,EAAMpE,KACdxD,EAAMqK,uBAKFrK,EAAMqJ,QACR,MAIU,OAAVzB,IAAgB5H,EAAMmK,oBAAsB,MAGlDnK,EAAMgK,gBAAkBpC,EACxB5H,EAAMuJ,kBAAmB,EAiC3B,SAASQ,GAAW/J,GAClB,OAAOA,EAAMiJ,QAA2B,IAAjBjJ,EAAM5D,QAA0C,OAA1B4D,EAAMgK,kBAA6BhK,EAAMkJ,WAAalJ,EAAMqJ,QAE3G,SAAS8B,GAAU7N,EAAQ0C,GACzB1C,EAAOqN,QAAO,SAAUhJ,GACtB3B,EAAMgI,YACFrG,GACFrE,EAAOoD,KAAK,QAASiB,GAEvB3B,EAAMoK,aAAc,EACpB9M,EAAOoD,KAAK,aACZkJ,GAAYtM,EAAQ0C,MAgBxB,SAAS4J,GAAYtM,EAAQ0C,GAC3B,IAAIoL,EAAOrB,GAAW/J,GAQtB,OAPIoL,KAfN,SAAmB9N,EAAQ0C,GACpBA,EAAMoK,aAAgBpK,EAAMgJ,cACF,mBAAlB1L,EAAOqN,QAChB3K,EAAMgI,YACNhI,EAAMgJ,aAAc,EACpBzN,GAAI8G,SAAS8I,GAAW7N,EAAQ0C,KAEhCA,EAAMoK,aAAc,EACpB9M,EAAOoD,KAAK,eAQd2K,CAAU/N,EAAQ0C,GACM,IAApBA,EAAMgI,YACRhI,EAAMkJ,UAAW,EACjB5L,EAAOoD,KAAK,YAGT0K,EAzhBT1O,GAAKG,SAASsL,GAAU9L,IAmHxBmM,GAAc5H,UAAU0K,UAAY,WAGlC,IAFA,IAAIC,EAAU/N,KAAKwM,gBACfwB,EAAM,GACHD,GACLC,EAAItL,KAAKqL,GACTA,EAAUA,EAAQ/H,KAEpB,OAAOgI,GAGT,WACE,IACE7O,OAAO0E,eAAemH,GAAc5H,UAAW,SAAU,CACvDU,IAAKmH,GAAaC,WAAU,WAC1B,OAAOlL,KAAK8N,cACX,6EAAmF,aAExF,MAAOG,KAPX,GAasB,mBAAXC,QAAyBA,OAAOC,aAAiE,mBAA3CC,SAAShL,UAAU8K,OAAOC,cACzFhD,GAAkBiD,SAAShL,UAAU8K,OAAOC,aAC5ChP,OAAO0E,eAAe8G,GAAUuD,OAAOC,YAAa,CAClDnK,MAAO,SAAUqK,GACf,QAAIlD,GAAgBjJ,KAAKlC,KAAMqO,IAC3BrO,OAAS2K,KAEN0D,GAAUA,EAAO7F,0BAA0BwC,QAItDG,GAAkB,SAAUkD,GAC1B,OAAOA,aAAkBrO,MAqC7B2K,GAASvH,UAAUgE,KAAO,WACxBpH,KAAKkD,KAAK,QAAS,IAAIK,MAAM,+BA8B/BoH,GAASvH,UAAUK,MAAQ,SAAUrB,EAAOT,EAAUyC,GACpD,IAnOqBvB,EAmOjBL,EAAQxC,KAAKwI,eACblD,GAAM,EACNoI,GAASlL,EAAMvC,aArOE4C,EAqO0BT,EApOxCtD,GAAOgE,SAASD,IAAQA,aAAe9D,IAwP9C,OAlBI2O,IAAU5O,GAAOgE,SAASV,KAC5BA,EA3OJ,SAA6BA,GAC3B,OAAOtD,GAAOuE,KAAKjB,GA0OTkB,CAAoBlB,IAGN,mBAAbT,IACTyC,EAAKzC,EACLA,EAAW,MAGT+L,EAAO/L,EAAW,SAAmBA,IAAUA,EAAWa,EAAMjB,iBAElD,mBAAP6C,IAAmBA,EAAKgH,IAE/B5I,EAAM1B,MA7CZ,SAAuBhB,EAAQsE,GAC7B,IAAI7B,EAAK,IAAIgB,MAAM,mBAEnBzD,EAAOoD,KAAK,QAASX,GACrBxE,GAAI8G,SAAST,EAAI7B,GAyCA+L,CAActO,KAAMoE,IAAasJ,GAnCpD,SAAoB5N,EAAQ0C,EAAOJ,EAAOgC,GACxC,IAAImK,GAAQ,EACRhM,GAAK,EAYT,OAVc,OAAVH,EACFG,EAAK,IAAIS,UAAU,uCACO,iBAAVZ,QAAgCW,IAAVX,GAAwBI,EAAMvC,aACpEsC,EAAK,IAAIS,UAAU,oCAEjBT,IACFzC,EAAOoD,KAAK,QAASX,GACrBxE,GAAI8G,SAAST,EAAI7B,GACjBgM,GAAQ,GAEHA,EAqBoDC,CAAWxO,KAAMwC,EAAOJ,EAAOgC,MACxF5B,EAAMgI,YACNlF,EAkDJ,SAAuBxF,EAAQ0C,EAAOkL,EAAOtL,EAAOT,EAAUyC,GAC5D,IAAKsJ,EAAO,CACV,IAAIe,EAtBR,SAAqBjM,EAAOJ,EAAOT,GAC5Ba,EAAMvC,aAAsC,IAAxBuC,EAAMoJ,eAA4C,iBAAVxJ,IAC/DA,EAAQtD,GAAOuE,KAAKjB,EAAOT,IAE7B,OAAOS,EAkBUsM,CAAYlM,EAAOJ,EAAOT,GACrCS,IAAUqM,IACZf,GAAQ,EACR/L,EAAW,SACXS,EAAQqM,GAGZ,IAAIxJ,EAAMzC,EAAMvC,WAAa,EAAImC,EAAMxD,OAEvC4D,EAAM5D,QAAUqG,EAEhB,IAAIK,EAAM9C,EAAM5D,OAAS4D,EAAMpC,cAE1BkF,IAAK9C,EAAMiG,WAAY,GAE5B,GAAIjG,EAAMqJ,SAAWrJ,EAAMsJ,OAAQ,CACjC,IAAI6C,EAAOnM,EAAMmK,oBACjBnK,EAAMmK,oBAAsB,CAC1BvK,MAAOA,EACPT,SAAUA,EACV+L,MAAOA,EACPnD,SAAUnG,EACV4B,KAAM,MAEJ2I,EACFA,EAAK3I,KAAOxD,EAAMmK,oBAElBnK,EAAMgK,gBAAkBhK,EAAMmK,oBAEhCnK,EAAMqK,sBAAwB,OAE9BO,GAAQtN,EAAQ0C,GAAO,EAAOyC,EAAK7C,EAAOT,EAAUyC,GAGtD,OAAOkB,EAtFCsJ,CAAc5O,KAAMwC,EAAOkL,EAAOtL,EAAOT,EAAUyC,IAGpDkB,GAGTqF,GAASvH,UAAUyL,KAAO,WACZ7O,KAAKwI,eAEXsD,UAGRnB,GAASvH,UAAU0L,OAAS,WAC1B,IAAItM,EAAQxC,KAAKwI,eAEbhG,EAAMsJ,SACRtJ,EAAMsJ,SAEDtJ,EAAMqJ,SAAYrJ,EAAMsJ,QAAWtJ,EAAMkJ,UAAalJ,EAAMuJ,mBAAoBvJ,EAAMgK,iBAAiBC,GAAYzM,KAAMwC,KAIlImI,GAASvH,UAAU2L,mBAAqB,SAA4BpN,GAGlE,GADwB,iBAAbA,IAAuBA,EAAWA,EAASqN,iBAChD,CAAC,MAAO,OAAQ,QAAS,QAAS,SAAU,SAAU,OAAQ,QAAS,UAAW,WAAY,OAAOpI,SAASjF,EAAW,IAAIqN,gBAAkB,GAAI,MAAM,IAAIhM,UAAU,qBAAuBrB,GAEpM,OADA3B,KAAKwI,eAAejH,gBAAkBI,EAC/B3B,MAUTb,OAAO0E,eAAe8G,GAASvH,UAAW,wBAAyB,CAIjE6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAKwI,eAAepI,iBA8L/BuK,GAASvH,UAAU2J,OAAS,SAAU3K,EAAOT,EAAUyC,GACrDA,EAAG,IAAIb,MAAM,iCAGfoH,GAASvH,UAAU6J,QAAU,KAE7BtC,GAASvH,UAAUX,IAAM,SAAUL,EAAOT,EAAUyC,GAClD,IAAI5B,EAAQxC,KAAKwI,eAEI,mBAAVpG,GACTgC,EAAKhC,EACLA,EAAQ,KACRT,EAAW,MACkB,mBAAbA,IAChByC,EAAKzC,EACLA,EAAW,MAGTS,SAAuCpC,KAAKyD,MAAMrB,EAAOT,GAGzDa,EAAMsJ,SACRtJ,EAAMsJ,OAAS,EACf9L,KAAK8O,UAIFtM,EAAMiJ,QAAWjJ,EAAMkJ,UA0C9B,SAAqB5L,EAAQ0C,EAAO4B,GAClC5B,EAAMiJ,QAAS,EACfW,GAAYtM,EAAQ0C,GAChB4B,IACE5B,EAAMkJ,SAAU3N,GAAI8G,SAAST,GAAStE,EAAO4I,KAAK,SAAUtE,IAElE5B,EAAM1B,OAAQ,EACdhB,EAAOgN,UAAW,EAjDoBmC,CAAYjP,KAAMwC,EAAO4B,IAoEjEjF,OAAO0E,eAAe8G,GAASvH,UAAW,YAAa,CACrDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAKwI,gBAGFxI,KAAKwI,eAAelH,WAE7ByC,IAAK,SAAUC,GAGRhE,KAAKwI,iBAMVxI,KAAKwI,eAAelH,UAAY0C,MAIpC2G,GAASvH,UAAUpB,QAAUrC,GAAYqC,QACzC2I,GAASvH,UAAUa,WAAatE,GAAYuE,UAC5CyG,GAASvH,UAAUnB,SAAW,SAAUkC,EAAKC,GAC3CpE,KAAKyC,MACL2B,EAAGD,mDC3qBkB,IAAZsD,IACNA,EAAQqD,SAC0B,IAAnCrD,EAAQqD,QAAQlE,QAAQ,QACW,IAAnCa,EAAQqD,QAAQlE,QAAQ,QAAqD,IAArCa,EAAQqD,QAAQlE,QAAQ,SAClE3I,OAAOC,QAAU,CAAE2G,SAKrB,SAAkBmE,EAAIkG,EAAMC,EAAMC,GAChC,GAAkB,mBAAPpG,EACT,MAAM,IAAIhG,UAAU,0CAEtB,IACIqM,EAAMtI,EADN9B,EAAM8E,UAAUnL,OAEpB,OAAQqG,GACR,KAAK,EACL,KAAK,EACH,OAAOwC,EAAQ5C,SAASmE,GAC1B,KAAK,EACH,OAAOvB,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,MAElB,KAAK,EACH,OAAOzH,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,EAAMC,MAExB,KAAK,EACH,OAAO1H,EAAQ5C,UAAS,WACtBmE,EAAG9G,KAAK,KAAMgN,EAAMC,EAAMC,MAE9B,QAGE,IAFAC,EAAO,IAAI/B,MAAMrI,EAAM,GACvB8B,EAAI,EACGA,EAAIsI,EAAKzQ,QACdyQ,EAAKtI,KAAOgD,UAAUhD,GAExB,OAAOU,EAAQ5C,UAAS,WACtBmE,EAAGc,MAAM,KAAMuF,SAhCnBpR,OAAOC,QAAUuJ,y6qBCgGnB,SAAS6H,GAAeC,GACtB,OAAOpQ,OAAOiE,UAAUoM,SAAStN,KAAKqN,GA3EzBrQ,GAAAb,QANf,SAAiBoR,GACf,OAAInC,MAAMjP,QACDiP,MAAMjP,QAAQoR,GAEQ,mBAAxBH,GAAeG,IAOPvQ,GAAAwQ,UAHjB,SAAmBD,GACjB,MAAsB,kBAARA,GAOFvQ,GAAAyQ,OAHd,SAAgBF,GACd,OAAe,OAARA,GAOgBvQ,GAAA0Q,kBAHzB,SAA2BH,GACzB,OAAc,MAAPA,GAOOvQ,GAAA2Q,SAHhB,SAAkBJ,GAChB,MAAsB,iBAARA,GAOAvQ,GAAA4Q,SAHhB,SAAkBL,GAChB,MAAsB,iBAARA,GAOAvQ,GAAA6Q,SAHhB,SAAkBN,GAChB,MAAsB,iBAARA,GAOGvQ,GAAA8Q,YAHnB,SAAqBP,GACnB,YAAe,IAARA,GAOOvQ,GAAA+Q,SAHhB,SAAkBC,GAChB,MAA8B,oBAAvBZ,GAAeY,IAORhR,GAAAiR,SAHhB,SAAkBV,GAChB,MAAsB,iBAARA,GAA4B,OAARA,GAOtBvQ,GAAAkR,OAHd,SAAgBC,GACd,MAA6B,kBAAtBf,GAAee,IAOTnR,GAAAoR,QAHf,SAAiBC,GACf,MAA8B,mBAAtBjB,GAAeiB,IAA2BA,aAAahN,OAO/CrE,GAAAsR,WAHlB,SAAoBf,GAClB,MAAsB,mBAARA,GAYGvQ,GAAAuR,YARnB,SAAqBhB,GACnB,OAAe,OAARA,GACe,kBAARA,GACQ,iBAARA,GACQ,iBAARA,GACQ,iBAARA,QACQ,IAARA,GAIhBvQ,GAAA4D,SAAmB4N,GAAkB5R,OAAOgE,sVCxExC/E,GAAM2S,GAINC,GAAaxR,OAAOyR,MAAQ,SAAU/N,GACxC,IAAI+N,EAAO,GACX,IAAK,IAAIC,KAAOhO,EACd+N,EAAKlO,KAAKmO,GACX,OAAOD,GAIVE,GAAiB1S,GAGbc,GAAOC,OAAOC,OAAO2R,IACzB7R,GAAKG,SAAW2R,GAGhB,IAAI7S,GAAW8S,GACXtG,GAAWuG,GAEfhS,GAAKG,SAASjB,GAAQD,IAKpB,IADA,IAAIyS,GAAOD,GAAWhG,GAASvH,WACtB+N,GAAI,EAAGA,GAAIP,GAAKhS,OAAQuS,KAAK,CACpC,IAAItH,GAAS+G,GAAKO,IACb/S,GAAOgF,UAAUyG,MAASzL,GAAOgF,UAAUyG,IAAUc,GAASvH,UAAUyG,KAIjF,SAASzL,GAAOyB,GACd,KAAMG,gBAAgB5B,IAAS,OAAO,IAAIA,GAAOyB,GAEjD1B,GAAS+D,KAAKlC,KAAMH,GACpB8K,GAASzI,KAAKlC,KAAMH,GAEhBA,IAAgC,IAArBA,EAAQgC,WAAoB7B,KAAK6B,UAAW,GAEvDhC,IAAgC,IAArBA,EAAQiN,WAAoB9M,KAAK8M,UAAW,GAE3D9M,KAAKoR,eAAgB,EACjBvR,IAAqC,IAA1BA,EAAQuR,gBAAyBpR,KAAKoR,eAAgB,GAErEpR,KAAK0I,KAAK,MAAOd,IAcnB,SAASA,KAGH5H,KAAKoR,eAAiBpR,KAAKwI,eAAe1H,OAI9C/C,GAAI8G,SAASwM,GAASrR,MAGxB,SAASqR,GAAQlM,GACfA,EAAK1C,MAtBPtD,OAAO0E,eAAezF,GAAOgF,UAAW,wBAAyB,CAI/D6G,YAAY,EACZnG,IAAK,WACH,OAAO9D,KAAKwI,eAAepI,iBAmB/BjB,OAAO0E,eAAezF,GAAOgF,UAAW,YAAa,CACnDU,IAAK,WACH,YAA4Bf,IAAxB/C,KAAK4B,qBAAwDmB,IAAxB/C,KAAKwI,iBAGvCxI,KAAK4B,eAAeN,WAAatB,KAAKwI,eAAelH,YAE9DyC,IAAK,SAAUC,QAGejB,IAAxB/C,KAAK4B,qBAAwDmB,IAAxB/C,KAAKwI,iBAM9CxI,KAAK4B,eAAeN,UAAY0C,EAChChE,KAAKwI,eAAelH,UAAY0C,MAIpC5F,GAAOgF,UAAUnB,SAAW,SAAUkC,EAAKC,GACzCpE,KAAK0C,KAAK,MACV1C,KAAKyC,MAEL1E,GAAI8G,SAAST,EAAID,QChEnBmN,GAAiBC,GAEbnT,GAASsS,GAGTxR,GAAOC,OAAOC,OAAO2R,IAMzB,SAASS,GAAejP,EAAIoC,GAC1B,IAAI8M,EAAKzR,KAAK0R,gBACdD,EAAGE,cAAe,EAElB,IAAIvN,EAAKqN,EAAGxF,QAEZ,IAAK7H,EACH,OAAOpE,KAAKkD,KAAK,QAAS,IAAIK,MAAM,yCAGtCkO,EAAGG,WAAa,KAChBH,EAAGxF,QAAU,KAED,MAARtH,GACF3E,KAAK0C,KAAKiC,GAEZP,EAAG7B,GAEH,IAAIsP,EAAK7R,KAAK4B,eACdiQ,EAAG7Q,SAAU,GACT6Q,EAAG3Q,cAAgB2Q,EAAGjT,OAASiT,EAAGzR,gBACpCJ,KAAK+B,MAAM8P,EAAGzR,eAIlB,SAASmR,GAAU1R,GACjB,KAAMG,gBAAgBuR,IAAY,OAAO,IAAIA,GAAU1R,GAEvDzB,GAAO8D,KAAKlC,KAAMH,GAElBG,KAAK0R,gBAAkB,CACrBF,eAAgBA,GAAexH,KAAKhK,MACpC8R,eAAe,EACfH,cAAc,EACd1F,QAAS,KACT2F,WAAY,KACZG,cAAe,MAIjB/R,KAAK4B,eAAeV,cAAe,EAKnClB,KAAK4B,eAAeX,MAAO,EAEvBpB,IAC+B,mBAAtBA,EAAQmS,YAA0BhS,KAAKiS,WAAapS,EAAQmS,WAE1C,mBAAlBnS,EAAQqS,QAAsBlS,KAAKmS,OAAStS,EAAQqS,QAIjElS,KAAK2I,GAAG,YAAakF,IAGvB,SAASA,KACP,IAAIlE,EAAQ3J,KAEe,mBAAhBA,KAAKmS,OACdnS,KAAKmS,QAAO,SAAU5P,EAAIoC,GACxByN,GAAKzI,EAAOpH,EAAIoC,MAGlByN,GAAKpS,KAAM,KAAM,MA2DrB,SAASoS,GAAKtS,EAAQyC,EAAIoC,GACxB,GAAIpC,EAAI,OAAOzC,EAAOoD,KAAK,QAASX,GAOpC,GALY,MAARoC,GACF7E,EAAO4C,KAAKiC,GAIV7E,EAAO0I,eAAe5J,OAAQ,MAAM,IAAI2E,MAAM,8CAElD,GAAIzD,EAAO4R,gBAAgBC,aAAc,MAAM,IAAIpO,MAAM,kDAEzD,OAAOzD,EAAO4C,KAAK,MA7IrBxD,GAAKG,SAAW2R,GAGhB9R,GAAKG,SAASkS,GAAWnT,IAuEzBmT,GAAUnO,UAAUV,KAAO,SAAUN,EAAOT,GAE1C,OADA3B,KAAK0R,gBAAgBI,eAAgB,EAC9B1T,GAAOgF,UAAUV,KAAKR,KAAKlC,KAAMoC,EAAOT,IAajD4P,GAAUnO,UAAU6O,WAAa,SAAU7P,EAAOT,EAAUyC,GAC1D,MAAM,IAAIb,MAAM,oCAGlBgO,GAAUnO,UAAU2J,OAAS,SAAU3K,EAAOT,EAAUyC,GACtD,IAAIqN,EAAKzR,KAAK0R,gBAId,GAHAD,EAAGxF,QAAU7H,EACbqN,EAAGG,WAAaxP,EAChBqP,EAAGM,cAAgBpQ,GACd8P,EAAGE,aAAc,CACpB,IAAIE,EAAK7R,KAAK4B,gBACV6P,EAAGK,eAAiBD,EAAG3Q,cAAgB2Q,EAAGjT,OAASiT,EAAGzR,gBAAeJ,KAAK+B,MAAM8P,EAAGzR,iBAO3FmR,GAAUnO,UAAUrB,MAAQ,SAAU0C,GACpC,IAAIgN,EAAKzR,KAAK0R,gBAEQ,OAAlBD,EAAGG,YAAuBH,EAAGxF,UAAYwF,EAAGE,cAC9CF,EAAGE,cAAe,EAClB3R,KAAKiS,WAAWR,EAAGG,WAAYH,EAAGM,cAAeN,EAAGD,iBAIpDC,EAAGK,eAAgB,GAIvBP,GAAUnO,UAAUnB,SAAW,SAAUkC,EAAKC,GAC5C,IAAIiO,EAASrS,KAEb5B,GAAOgF,UAAUnB,SAASC,KAAKlC,KAAMmE,GAAK,SAAUmO,GAClDlO,EAAGkO,GACHD,EAAOnP,KAAK,iBCzKhBqP,GAAiBC,GAEbjB,GAAYb,GAGZxR,GAAOC,OAAOC,OAAO2R,IAMzB,SAASyB,GAAY3S,GACnB,KAAMG,gBAAgBwS,IAAc,OAAO,IAAIA,GAAY3S,GAE3D0R,GAAUrP,KAAKlC,KAAMH,GARvBX,GAAKG,SAAW2R,GAGhB9R,GAAKG,SAASmT,GAAajB,IAQ3BiB,GAAYpP,UAAU6O,WAAa,SAAU7P,EAAOT,EAAUyC,GAC5DA,EAAG,KAAMhC,mBC7CXlE,EAAUD,EAAiBC,QAAAwS,IAC3B7R,OAAiBX,EACjBA,EAAAC,SAAmBD,EACnBA,EAAAyM,SAAmBoG,GACnB7S,EAAAE,OAAiB4S,GACjB9S,EAAAqT,UAAoBN,GACpB/S,EAAAsU,YAAsBtB,+DCkDtB,SAASuB,GAAUC,EAAM7S,GACxB,OAAMsQ,EAAUtQ,GAGX8S,EAAY9S,EAAS,SACzB6S,EAAKE,IAAM/S,EAAQ+S,KACb9C,EAAU4C,EAAKE,MACb,IAAI5P,UAAW6P,EAAQ,QAAS,MAAOH,EAAKE,MAGhDD,EAAY9S,EAAS,gBACzB6S,EAAKzS,WAAaJ,EAAQI,YACpByP,EAAWgD,EAAKzS,aACd,IAAI+C,UAAW6P,EAAQ,QAAS,aAAcH,EAAKzS,aAGvD0S,EAAY9S,EAAS,cACzB6S,EAAK/Q,SAAW9B,EAAQ8B,UAClBmO,EAAU4C,EAAK/Q,WAAgC,OAAlB+Q,EAAK/Q,UAChC,IAAIqB,UAAW6P,EAAQ,QAAS,WAAYH,EAAK/Q,WAGrDgR,EAAY9S,EAAS,mBACzB6S,EAAKtS,cAAgBP,EAAQO,eACvB0S,EAAeJ,EAAKtS,gBAClB,IAAI4C,UAAW6P,EAAQ,QAAS,gBAAiBH,EAAKtS,gBAG1DuS,EAAY9S,EAAS,eACzB6S,EAAKK,UAAYlT,EAAQkT,WACnBvC,EAAYkC,EAAKK,YACf,IAAI/P,UAAW6P,EAAQ,QAAS,YAAaH,EAAKK,YAGpD,KAhCC,IAAI/P,UAAW6P,EAAQ,QAAShT,QC/BrCN,UC0JJ,SAASyT,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQtT,GACvD,IAAI6S,EACAvO,EACA4C,EACJ,KAAQ/G,gBAAgBgT,IACvB,OAAKjJ,UAAUnL,OAAS,EAChB,IAAIoU,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQtT,GAEpD,IAAImT,GAAoBC,EAAGvS,EAAQwS,EAAQC,GAEnD,IAAMC,EAAsBH,GAC3B,MAAM,IAAIjQ,UAAW6P,EAAQ,QAASI,IAEvC,IAAMI,EAAc3S,GACnB,MAAM,IAAIsC,UAAW6P,EAAQ,QAASnS,IAEvC,IAAM4S,EAAWJ,GAChB,MAAM,IAAIlQ,UAAW6P,EAAQ,QAASK,IAEvC,IAAME,EAAsBD,GAC3B,MAAM,IAAInQ,UAAW6P,EAAQ,QAASM,IAEvC,GAAKF,EAAI,IACRlM,EAAIoM,GAAWF,EAAE,GAAGC,EACfC,GAAUzS,EAAO9B,QAAUmI,EAAI,GAAKA,GAAKrG,EAAO9B,QACpD,MAAM,IAAI2U,WAAYV,EAAQ,UAIhC,GADAH,EAAOpM,EAAMkN,IACRzJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EA+BR,OA3BA5E,GAAO,wEAAyEkU,KAAKC,UAAWhB,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBiB,EAAkB3T,KAAM,cAAc,GAGtC4T,EAA0B5T,KAAM,cAAe0S,EAAKzS,YAGpD2T,EAA0B5T,KAAM,OAAQ0S,EAAKE,KAG7CgB,EAA0B5T,KAAM,aAAc0S,EAAKK,WAAaU,KAAKC,WAGrEE,EAA0B5T,KAAM,UAAWU,GAG3CkT,EAA0B5T,KAAM,KAAMiT,GACtCW,EAA0B5T,KAAM,UAAWkT,GAC3CU,EAA0B5T,KAAM,UAAWmT,GAC3CQ,EAAkB3T,KAAM,OAAQmT,GAGhCQ,EAAkB3T,KAAM,KAAM,GAEvBA,KCjLR,SAASC,GAAYgT,EAAGvS,EAAQwS,EAAQC,EAAQtT,GAC/C,IAAI6S,EACJ,GAAK3I,UAAUnL,OAAS,EAAI,CAE3B,IAAMuR,EADNuC,EAAO7S,GAEN,MAAM,IAAImD,UAAW6P,EAAQ,QAASH,IAEvCA,EAAOpM,EAAMzG,EAAS,QAEtB6S,EAAO,GAGR,OADAA,EAAKzS,YAAa,EACX,IAAI+S,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQT,GCf3D,SAASmB,GAAShU,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAEDiU,EAeP,SAASA,EAAcb,EAAGvS,EAAQwS,EAAQC,GACzC,OAAO,IAAIH,GAAoBC,EAAGvS,EAAQwS,EAAQC,EAAQT,IFmK5DqB,EAASf,GAAoB7U,EAAAA,QAAAA,UAY7ByV,EAA0BZ,GAAmB5P,UAAW,SApNxD,WAEC,IAAI4Q,EACA7P,EACAgN,EAEJ,IAAKnR,KAAKiU,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA7P,EAAM,KAENnE,KAAKkU,IAAM,EACNlU,KAAKkU,GAAKlU,KAAKmU,GAEnB,OAAOnU,KAAK0C,KAAM,MAEnByO,EAAInR,KAAKoU,QAASpU,KAAKqU,MACvB9U,GAAO,gCAAiCkU,KAAKC,UAAWvC,GAAKnR,KAAKqU,KAAMrU,KAAKkU,IAE7ElU,KAAKqU,MAAQrU,KAAKsU,SACQ,IAArBtU,KAAKuU,cAES,iBADlBpD,EAAInR,KAAKwU,WAAYrD,IAGnBA,EADgB,IAAZnR,KAAKkU,GACLO,EAAetD,GAEfsD,EAAezU,KAAK0U,KAAKvD,GAEnBrO,EAAUqO,GAChBnR,KAAKkU,GAAK,IACd/C,EAAIrS,EAAO2G,OAAQ,CAAEgP,EAAezU,KAAK0U,MAAQvD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB6P,EAAMhU,KAAK0C,KAAMyO,OAsLpByC,EAA0BZ,GAAmB5P,UAAW,WAxKxD,SAAkBuR,GAEjB,IAAIxP,EACJ,OAAKnF,KAAKiU,aAIV9O,EAAOnF,KACPA,KAAKiU,YAAa,EAElBpP,GASA,WACM8P,IACJpV,GAAO,mDAAsD+Q,EAASqE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHxP,EAAKjC,KAAM,QAASyR,IAGrBxP,EAAKjC,KAAM,aApBJlD,QGPT6U,EAAA/U,GAAA,aAAAG,IACA4U,EAAA/U,GAAA,UAAA+T"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f0343ba..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 20b9a42ce2c738dae61d9e25b0f4fafeab5964ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 15:16:11 +0000 Subject: [PATCH 016/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 --- branches.md | 53 - docs/repl.txt | 155 -- docs/types/test.ts | 189 -- examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 --- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 376 --- test/test.js | 43 - test/test.main.js | 1139 --------- test/test.object_mode.js | 279 --- test/test.validate.js | 241 -- 47 files changed, 2724 insertions(+), 6604 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 2e97e13..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:37:45.074Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b0ec775 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..043a0c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fc09752..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2edfc3f --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 67f900b9c2603da10bfeda6978d92a2b7e952c40 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 03:44:09 +0000 Subject: [PATCH 017/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 0a779a9..fc09752 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From 383279aae1a77662a16fbd37d7a21a4b3b3ad813 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 14:29:01 +0000 Subject: [PATCH 018/112] Remove files --- index.d.ts | 305 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2999 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b0ec775..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 043a0c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2edfc3f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 9453b373e7ecc16cdaedc54b9a4fc813d4c331e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 14:29:53 +0000 Subject: [PATCH 019/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ------ test/test.object_mode.js | 279 -- test/test.validate.js | 241 -- 47 files changed, 4079 insertions(+), 6604 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 bb4fa23..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:25:54.980Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b0ec775 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..857bf09 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fc09752..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c9f7372 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From ef3ab2493c6fcb404bb84909620e718464f31236 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 22:03:59 +0000 Subject: [PATCH 020/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 0a779a9..fc09752 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From 7a154b11eb22981e8ebd11dabf7ff78db402fed5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 10:43:18 +0000 Subject: [PATCH 021/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4354 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b0ec775..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var v={exports:{}},_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function E(){throw new Error("setTimeout has not been defined")}function R(){throw new Error("clearTimeout has not been defined")}var j=E,S=R;function T(e){if(j===setTimeout)return setTimeout(e,0);if((j===E||!j)&&setTimeout)return j=setTimeout,setTimeout(e,0);try{return j(e,0)}catch(t){try{return j.call(null,e,0)}catch(t){return j.call(this,e,0)}}}"function"==typeof _.setTimeout&&(j=setTimeout),"function"==typeof _.clearTimeout&&(S=clearTimeout);var k,M=[],x=!1,A=-1;function P(){x&&k&&(x=!1,k.length?M=k.concat(M):A=-1,M.length&&O())}function O(){if(!x){var e=T(P);x=!0;for(var t=M.length;t;){for(k=M,M=[];++A1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===K.prototype||(t=function(e){return K.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):fe(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?fe(e,s,t,!1):de(e,s)):fe(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function le(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(te("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?J.nextTick(ce,e):ce(e))}function ce(e){te("emit readable"),e.emit("readable"),be(e)}function de(e,t){t.readingMore||(t.readingMore=!0,J.nextTick(pe,e,t))}function pe(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=K.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function me(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,J.nextTick(ve,t,e))}function ve(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function _e(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return te("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?me(this):le(this),null;if(0===(e=he(e,t))&&t.ended)return 0===t.length&&me(this),null;var n,i=t.needReadable;return te("need readable",i),(0===t.length||t.length-e0?we(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&me(this)),null!==n&&this.emit("data",n),n},ae.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},ae.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,te("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==H.stdout&&e!==H.stderr?s:p;function o(t,i){te("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,te("cleanup"),e.removeListener("close",c),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",p),r.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){te("onend"),e.end()}n.endEmitted?J.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;te("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Z(e,"data")&&(t.flowing=!0,be(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){te("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==_e(n.pipes,e))&&!u&&(te("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){te("onerror",t),p(),e.removeListener("error",l),0===Z(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){te("onfinish"),e.removeListener("close",c),p()}function p(){te("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?X(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",l),e.once("close",c),e.once("finish",d),e.emit("pipe",r),n.flowing||(te("pipe resume"),r.resume()),e},ae.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:Re.nextTick;Le.WritableState=Ce;var ke=Object.create(require("core-util-is"));ke.inherits=require("inherits");var Me={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Ae=require("safe-buffer").Buffer,Pe=_.Uint8Array||function(){};var Oe,Be=require("./internal/streams/destroy");function Ue(){}function Ce(e,t){Se=Se||require("./_stream_duplex"),e=e||{};var r=t instanceof Se;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(i||0===i)?i:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(Re.nextTick(i,n),Re.nextTick(Ne,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ne(e,t))}(e,r,n,t,i);else{var o=Ye(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||Ie(e,r),n?Te(qe,e,r,o,i):qe(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Le(e){if(Se=Se||require("./_stream_duplex"),!(Oe.call(Le,this)||this instanceof Se))return new Le(e);this._writableState=new Ce(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),xe.call(this)}function De(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function qe(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),Ne(e,t)}function Ie(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,De(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new je(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(De(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function Ye(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function We(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ne(e,t)}))}function Ne(e,t){var r=Ye(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Re.nextTick(We,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}ke.inherits(Le,xe),Ce.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ce.prototype,"buffer",{get:Me.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(Oe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Le,Symbol.hasInstance,{value:function(e){return!!Oe.call(this,e)||this===Le&&(e&&e._writableState instanceof Ce)}})):Oe=function(e){return e instanceof this},Le.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Le.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Ae.isBuffer(n)||n instanceof Pe);return s&&!Ae.isBuffer(e)&&(e=function(e){return Ae.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Ue),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Re.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Re.nextTick(n,o),i=!1),i}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Ae.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Le.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Le.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Le.prototype._writev=null,Le.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Ne(e,t),r&&(t.finished?Re.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Le.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Le.prototype.destroy=Be.destroy,Le.prototype._undestroy=Be.undestroy,Le.prototype._destroy=function(e,t){this.end(),t(e)};var ze=m(Object.freeze({__proto__:null}));void 0===H||!H.version||0===H.version.indexOf("v0.")||0===H.version.indexOf("v1.")&&0!==H.version.indexOf("v1.8.")?module.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,o,s=arguments.length;switch(s){case 0:case 1:return H.nextTick(e);case 2:return H.nextTick((function(){e.call(null,t)}));case 3:return H.nextTick((function(){e.call(null,t,r)}));case 4:return H.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+Je[i>>12&63]+Je[i>>6&63]+Je[63&i]);return o.join("")}function Qe(e){var t;Ze||Ge();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=Je[t>>2],i+=Je[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Je[t>>10],i+=Je[t>>4&63],i+=Je[t<<2&63],i+="="),o.push(i),o.join("")}function $e(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)}function et(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}var tt={}.toString,rt=Array.isArray||function(e){return"[object Array]"==tt.call(e)};st.TYPED_ARRAY_SUPPORT=void 0===_.TYPED_ARRAY_SUPPORT||_.TYPED_ARRAY_SUPPORT;var nt=it();function it(){return st.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(e,t){if(it()=it())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+it().toString(16)+" bytes");return 0|e}function ct(e){return!(null==e||!e._isBuffer)}function dt(e,t){if(ct(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Yt(e).length;default:if(n)return It(e).length;t=(""+t).toLowerCase(),n=!0}}function pt(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return Tt(this,t,r);case"latin1":case"binary":return kt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function gt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function yt(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=st.from(t,n)),ct(t))return 0===t.length?-1:bt(e,t,r,n,i);if("number"==typeof t)return t&=255,st.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bt(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function jt(e,t,r){return 0===t&&r===e.length?Qe(e):Qe(e.slice(t,r))}function St(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},st.prototype.compare=function(e,t,r,n,i){if(!ct(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return wt(this,e,t,r);case"utf8":case"utf-8":return mt(this,e,t,r);case"ascii":return vt(this,e,t,r);case"latin1":case"binary":return _t(this,e,t,r);case"base64":return Et(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Pt(e,t,r,n,i,o){if(!ct(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ot(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Bt(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Ut(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ct(e,t,r,n,i){return i||Ut(e,0,r,4),et(e,t,r,n,23,4),r+4}function Lt(e,t,r,n,i){return i||Ut(e,0,r,8),et(e,t,r,n,52,8),r+8}st.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},st.prototype.readUInt8=function(e,t){return t||At(e,1,this.length),this[e]},st.prototype.readUInt16LE=function(e,t){return t||At(e,2,this.length),this[e]|this[e+1]<<8},st.prototype.readUInt16BE=function(e,t){return t||At(e,2,this.length),this[e]<<8|this[e+1]},st.prototype.readUInt32LE=function(e,t){return t||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},st.prototype.readUInt32BE=function(e,t){return t||At(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},st.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},st.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||At(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},st.prototype.readInt8=function(e,t){return t||At(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},st.prototype.readInt16LE=function(e,t){t||At(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt16BE=function(e,t){t||At(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},st.prototype.readInt32LE=function(e,t){return t||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},st.prototype.readInt32BE=function(e,t){return t||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},st.prototype.readFloatLE=function(e,t){return t||At(e,4,this.length),$e(this,e,!0,23,4)},st.prototype.readFloatBE=function(e,t){return t||At(e,4,this.length),$e(this,e,!1,23,4)},st.prototype.readDoubleLE=function(e,t){return t||At(e,8,this.length),$e(this,e,!0,52,8)},st.prototype.readDoubleBE=function(e,t){return t||At(e,8,this.length),$e(this,e,!1,52,8)},st.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Pt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},st.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,255,0),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},st.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,65535,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Bt(this,e,t,!0),t+4},st.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,4294967295,0),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},st.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Pt(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},st.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,1,127,-128),st.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},st.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ot(this,e,t,!0),t+2},st.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,2,32767,-32768),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ot(this,e,t,!1),t+2},st.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),st.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Bt(this,e,t,!0),t+4},st.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Pt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),st.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Bt(this,e,t,!1),t+4},st.prototype.writeFloatLE=function(e,t,r){return Ct(this,e,t,!0,r)},st.prototype.writeFloatBE=function(e,t,r){return Ct(this,e,t,!1,r)},st.prototype.writeDoubleLE=function(e,t,r){return Lt(this,e,t,!0,r)},st.prototype.writeDoubleBE=function(e,t,r){return Lt(this,e,t,!1,r)},st.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!st.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Yt(e){return function(e){var t,r,n,i,o,s;Ze||Ge();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=Ve[e.charCodeAt(t)]<<2|Ve[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Ve[e.charCodeAt(t)]<<10|Ve[e.charCodeAt(t+1)]<<4|Ve[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Dt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Wt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||zt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&zt(e.slice(0,0))}(e))}function zt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Ft=m(Object.freeze({__proto__:null,Buffer:st,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),st.alloc(+e)},isBuffer:Nt,kMaxLength:nt}));function Ht(e){return Object.prototype.toString.call(e)}He.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ht(e)},He.isBoolean=function(e){return"boolean"==typeof e},He.isNull=function(e){return null===e},He.isNullOrUndefined=function(e){return null==e},He.isNumber=function(e){return"number"==typeof e},He.isString=function(e){return"string"==typeof e},He.isSymbol=function(e){return"symbol"==typeof e},He.isUndefined=function(e){return void 0===e},He.isRegExp=function(e){return"[object RegExp]"===Ht(e)},He.isObject=function(e){return"object"==typeof e&&null!==e},He.isDate=function(e){return"[object Date]"===Ht(e)},He.isError=function(e){return"[object Error]"===Ht(e)||e instanceof Error},He.isFunction=function(e){return"function"==typeof e},He.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},He.isBuffer=Ft.Buffer.isBuffer;var Jt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Vt=m(Object.freeze({__proto__:null,default:Jt})),Xt=Fe,Zt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Gt=nr,Kt=Object.create(He);Kt.inherits=Vt;var Qt=Ee,$t=ze;Kt.inherits(nr,Qt);for(var er=Zt($t.prototype),tr=0;tr{};function vr(r,n,a,f,h){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,f,h):new vr(r,n,a,f);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(f))throw new TypeError(l("0g23C",f));if(r>0&&(p=f+(r-1)*a,f>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(br),arguments.length>4&&(d=wr(c,h)))throw d;return mr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),v.exports.Readable.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",f),u(this,"_idx",f),u(this,"_i",0),this}function _r(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function Er(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,v.exports.Readable),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return this.push(null);r=this._buffer[this._idx],mr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?f(r):f(this._sep+r):n(r)?this._i>1&&(r=h.concat([f(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,c((function(){e&&(mr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));t.emit("close")}))),this})),e(vr,"objectMode",_r),e(vr,"factory",Er);export{vr as default,Er as factory,_r as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 857bf09..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/process-nextick-args/index.js","../node_modules/core-util-is/lib/util.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/readable-browser.js","../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};","'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","exports = module.exports = require('./lib/_stream_readable.js');\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = require('./lib/_stream_writable.js');\nexports.Duplex = require('./lib/_stream_duplex.js');\nexports.Transform = require('./lib/_stream_transform.js');\nexports.PassThrough = require('./lib/_stream_passthrough.js');\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport logger from 'debug' ;\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { Readable as Readable } from 'readable-stream' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["pna","require","module","exports","Readable","Duplex","isArray","ReadableState","EventEmitter","EElistenerCount","emitter","type","listeners","length","Stream","Buffer","OurUint8Array","global","Uint8Array","util","Object","create","inherits","debugUtil","debug","debuglog","StringDecoder","BufferList","destroyImpl","kProxyEvents","options","stream","isDuplex","this","objectMode","readableObjectMode","hwm","highWaterMark","readableHwm","readableHighWaterMark","defaultHwm","Math","floor","buffer","pipes","pipesCount","flowing","ended","endEmitted","reading","sync","needReadable","emittedReadable","readableListening","resumeScheduled","destroyed","defaultEncoding","awaitDrain","readingMore","decoder","encoding","_readableState","readable","read","_read","destroy","_destroy","call","readableAddChunk","chunk","addToFront","skipChunkCheck","er","state","end","push","emitReadable","onEofChunk","obj","isBuffer","undefined","TypeError","chunkInvalid","emit","getPrototypeOf","prototype","from","_uint8ArrayToBuffer","Error","addChunk","write","maybeReadMore","needMoreData","unshift","defineProperty","get","set","value","_undestroy","undestroy","err","cb","isPaused","setEncoding","enc","howMuchToRead","n","head","data","computeNewHighWaterMark","nextTick","emitReadable_","flow","maybeReadMore_","len","nReadingNextTick","self","resume_","fromList","ret","shift","join","concat","clear","list","hasStrings","slice","p","c","next","str","nb","tail","copyFromBufferString","allocUnsafe","copy","buf","copyFromBuffer","fromListPartial","endReadable","endReadableNT","indexOf","xs","x","i","l","parseInt","nOrig","doRead","pipe","dest","pipeOpts","src","endFn","process","stdout","stderr","onend","unpipe","onunpipe","unpipeInfo","hasUnpiped","removeListener","onclose","onfinish","ondrain","onerror","ondata","cleanedUp","_writableState","needDrain","once","on","pipeOnDrain","increasedAwaitDrain","pause","event","fn","prependListener","_events","resume","dests","index","splice","ev","res","addListener","wrap","_this","paused","method","apply","arguments","bind","enumerable","_fromList","CorkedRequest","entry","finish","corkReq","callback","pendingcb","corkedRequestsFree","onCorkedFinish","Writable","asyncWrite","browser","version","setImmediate","WritableState","internalUtil","deprecate","realHasInstance","nop","writableObjectMode","writableHwm","writableHighWaterMark","finalCalled","ending","finished","noDecode","decodeStrings","writing","corked","bufferProcessing","onwrite","writecb","writelen","onwriteStateUpdate","finishMaybe","errorEmitted","onwriteError","needFinish","bufferedRequest","clearBuffer","afterWrite","lastBufferedRequest","prefinished","bufferedRequestCount","writable","_write","writev","_writev","final","_final","doWrite","onwriteDrain","Array","holder","count","allBuffers","isBuf","callFinal","need","prefinish","getBuffer","current","out","_","Symbol","hasInstance","Function","object","writeAfterEnd","valid","validChunk","newChunk","decodeChunk","last","writeOrBuffer","cork","uncork","setDefaultEncoding","toLowerCase","endWritable","arg1","arg2","arg3","args","objectToString","o","toString","arg","isBoolean","isNull","isNullOrUndefined","isNumber","isString","isSymbol","isUndefined","isRegExp","re","isObject","isDate","d","isError","e","isFunction","isPrimitive","require$$0","objectKeys","keys","key","_stream_duplex","require$$1","require$$2","require$$3","require$$4","v","allowHalfOpen","onEndNT","_stream_transform","Transform","afterTransform","ts","_transformState","transforming","writechunk","rs","needTransform","writeencoding","transform","_transform","flush","_flush","done","_this2","err2","_stream_passthrough","PassThrough","validate","opts","hasOwnProp","sep","format","isNonNegative","serialize","StridedArrayStream","N","stride","offset","isNonNegativeInteger","isCollection","isInteger","RangeError","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_N","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c9f7372..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 3dc2bb75c26583ee8d5821d330f4ecbe65f5ef96 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 10:44:17 +0000 Subject: [PATCH 022/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ------ test/test.object_mode.js | 279 -- test/test.validate.js | 241 -- 47 files changed, 4079 insertions(+), 6625 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 a3b6ac7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:03:23.417Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9f9856d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..095e0d0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fc09752..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a1634be --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 4a8f285987f216ca9e276569d791ac36b164a240 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:03:07 +0000 Subject: [PATCH 023/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 9217175..1847e36 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From 97fd32f0867d98b8136211281a5d2e93b7c7bfed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 17:37:43 +0000 Subject: [PATCH 024/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4354 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9f9856d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 095e0d0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isError from '@stdlib/assert-is-error' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property' ;\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport string2buffer from '@stdlib/buffer-from-string' ;\nimport Buffer from '@stdlib/buffer-ctor' ; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport nextTick from '@stdlib/utils-next-tick' ;\nimport DEFAULTS from './defaults.json' ;\nimport validate from './validate.js' ;\nimport debug from './debug.js' ;\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy' ;\nimport StridedArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink' ;\n* import Float64Array from '@stdlib/array-float64' ;\n* import randu from '@stdlib/random-base-randu' ;\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array' ;\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport objectMode from './object_mode.js' ;\nimport factory from './factory.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a1634be..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From deebd620473f7ebc41fc0b62aac26f501e7e61c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 17:38:58 +0000 Subject: [PATCH 025/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ------ test/test.object_mode.js | 279 -- test/test.validate.js | 241 -- 47 files changed, 4079 insertions(+), 6630 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 a49718f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:52:55.135Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9f9856d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..088cc62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 1847e36..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0af1c8d --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From a94163b53237151e858a06bb34531fe8ca78c2b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:23:18 +0000 Subject: [PATCH 026/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index dd4458f..17a2d08 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From 37047d352221056917aad45123f9e9983a2bcd83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 11:03:23 +0000 Subject: [PATCH 027/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4354 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9f9856d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 088cc62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0af1c8d..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e4b9c32759cb970152923d5a5abb2f92466b8448 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 11:04:26 +0000 Subject: [PATCH 028/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ------ test/test.object_mode.js | 279 -- test/test.validate.js | 241 -- 47 files changed, 4079 insertions(+), 6641 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 f80cb01..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:16:17.609Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8f2009e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..088cc62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 17a2d08..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5f61694 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 29494e441a915b9cdd786f39e416ef4fb980834e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:51:46 +0000 Subject: [PATCH 029/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index dd4458f..17a2d08 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/buffer-ctor": "^0.0.x", "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-property": "^0.0.x", From db373086fcecc00453b545f6c627cc4b0a3e5c2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 15:06:24 +0000 Subject: [PATCH 030/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4354 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8f2009e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 088cc62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5f61694..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From fc90c1206cd3b3c0229c9c44431ad3f6695df6d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 15:07:18 +0000 Subject: [PATCH 031/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 47 files changed, 6212 insertions(+), 6641 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 e509c45..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:40:51.083Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index cc4d852..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/streams/node/from-strided-array" -click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c141c95 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..68d7482 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 17a2d08..53869e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-nonnegative-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/buffer-ctor": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/streams-node-inspect-sink": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ecb9a48 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From cd2038336df3e8c1c38f81d37abf8f73dd83d1bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 06:30:02 +0000 Subject: [PATCH 032/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f619f63..ec1f264 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", From 5955c9ab818476f585be67accc4de0dacc56ab90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 15:36:15 +0000 Subject: [PATCH 033/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c141c95..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 68d7482..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ecb9a48..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a509bdd082b00f7d6d48e3d660fbd68251c67cfb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 15:37:04 +0000 Subject: [PATCH 034/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 47 files changed, 6212 insertions(+), 6776 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 3991611..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T04:11:03.987Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c141c95 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..68d7482 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ec1f264..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3d10b7e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 192b55e78c2b1aae7a1b31c81b6b171c7850fd6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 07:02:52 +0000 Subject: [PATCH 035/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f619f63..ec1f264 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", From fc78d3e98e31f195193705c77a1a93ecb173bd7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 14:28:52 +0000 Subject: [PATCH 036/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c141c95..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 68d7482..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3d10b7e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7e7d513620d1c42187d4767970d164285a025de6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 14:29:58 +0000 Subject: [PATCH 037/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 47 files changed, 6212 insertions(+), 6782 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 77044e5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T04:47:55.000Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c141c95 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..68d7482 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ec1f264..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..24e7661 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From a34585db2741d46bf2c9bce4caecaaf3d5462ce8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 06:48:46 +0000 Subject: [PATCH 038/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f619f63..ec1f264 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", From f27cd4c2e2f319cec8723301502e16eff3b9fd16 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 14:12:42 +0000 Subject: [PATCH 039/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c141c95..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 68d7482..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 24e7661..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2de154ed88f717d9ff7fdc6708253dcdb5935c40 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 14:13:47 +0000 Subject: [PATCH 040/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 47 files changed, 6212 insertions(+), 6782 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 0e32bdc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T04:32:15.974Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c141c95 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..68d7482 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ec1f264..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1080ecd --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 000a73311f86c7022bf249bff20dc931af5a3f7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 06:29:37 +0000 Subject: [PATCH 041/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f619f63..ec1f264 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", From b375fb0cb4c70bf7d1d5956c7739d38c10acb138 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 14:30:39 +0000 Subject: [PATCH 042/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c141c95..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 68d7482..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1080ecd..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 99603902d21e1d3bb7d6248101db1de0e415b49b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 14:31:40 +0000 Subject: [PATCH 043/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 47 files changed, 6212 insertions(+), 6782 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 fc2059e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T04:10:23.571Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a1377ac..3bf1250 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 2.0 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c141c95 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..68d7482 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;qjxDAwDA,SAASA,GAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,SACzBD,EAAKI,IAAMH,EAAQG,KACbC,EAAUL,EAAKI,MACb,IAAIE,UAAWC,EAAQ,QAAS,MAAOP,EAAKI,MAGhDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,cACzBD,EAAKU,SAAWT,EAAQS,UAClBL,EAAUL,EAAKU,WAAgC,OAAlBV,EAAKU,UAChC,IAAIJ,UAAWC,EAAQ,QAAS,WAAYP,EAAKU,WAGrDP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBC,EAAeZ,EAAKW,gBAClB,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,eACzBD,EAAKa,UAAYZ,EAAQY,WACnBC,EAAYd,EAAKa,YACf,IAAIP,UAAWC,EAAQ,QAAS,YAAaP,EAAKa,YAGpD,KAhCC,IAAIP,UAAWC,EAAQ,QAASN,GAiCzC,KChEIc,wDAAQC,CAAQ,6BCLhBC,GAAWC,GAA6BD,SA+J5C,SAASE,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQtB,GACvD,IAAID,EACAwB,EACAC,EACJ,KAAQC,gBAAgBP,IACvB,OAAKQ,UAAUC,OAAS,EAChB,IAAIT,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQtB,GAEpD,IAAIkB,GAAoBC,EAAGC,EAAQC,EAAQC,GAEnD,IAAMM,EAAsBT,GAC3B,MAAM,IAAId,UAAWC,EAAQ,QAASa,IAEvC,IAAMU,EAAcT,GACnB,MAAM,IAAIf,UAAWC,EAAQ,QAASc,IAEvC,IAAMU,EAAWT,GAChB,MAAM,IAAIhB,UAAWC,EAAQ,QAASe,IAEvC,IAAMO,EAAsBN,GAC3B,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAEvC,GAAKH,EAAI,IACRK,EAAIF,GAAWH,EAAE,GAAGE,EACfC,GAAUF,EAAOO,QAAUH,EAAI,GAAKA,GAAKJ,EAAOO,QACpD,MAAM,IAAII,WAAYzB,EAAQ,UAIhC,GADAP,EAAOiC,EAAMC,IACRP,UAAUC,OAAS,IACvBJ,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EA+BR,OA3BAT,GAAO,wEAAyEoB,KAAKC,UAAWpC,IAChGiB,GAASoB,KAAMX,KAAM1B,GAGrBsC,EAAkBZ,KAAM,cAAc,GAGtCa,EAA0Bb,KAAM,cAAe1B,EAAKQ,YAGpD+B,EAA0Bb,KAAM,OAAQ1B,EAAKI,KAG7CmC,EAA0Bb,KAAM,aAAc1B,EAAKa,WAAasB,KAAKC,WAGrEG,EAA0Bb,KAAM,UAAWL,GAG3CkB,EAA0Bb,KAAM,KAAMN,GACtCmB,EAA0Bb,KAAM,UAAWJ,GAC3CiB,EAA0Bb,KAAM,UAAWH,GAC3Ce,EAAkBZ,KAAM,OAAQH,GAGhCe,EAAkBZ,KAAM,KAAM,GAEvBA,IACR,CClLA,SAASlB,GAAYY,EAAGC,EAAQC,EAAQC,EAAQtB,GAC/C,IAAID,EACJ,GAAK2B,UAAUC,OAAS,EAAI,CAE3B,IAAM1B,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAOiC,EAAMhC,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIW,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQvB,EAC3D,CChBA,SAASwC,GAASvC,GACjB,IAAID,EAMJ,OAJCA,EADI2B,UAAUC,OACPK,EAAMhC,EAAS,GAEf,CAAA,EAEDwC,EAeP,SAASA,EAAcrB,EAAGC,EAAQC,EAAQC,GACzC,OAAO,IAAIJ,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQvB,EAC1D,CACF,CFiKA0C,EAASvB,GAAoBF,IAY7BsB,EAA0BpB,GAAmBwB,UAAW,SApNxD,WAEC,IAAIC,EACApB,EACAqB,EAEJ,IAAKnB,KAAKoB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHApB,EAAM,KAENE,KAAKqB,IAAM,EACNrB,KAAKqB,GAAKrB,KAAKsB,GAEnB,OADAjC,GAAO,uBACAW,KAAKuB,KAAM,MAEnBJ,EAAInB,KAAKwB,QAASxB,KAAKyB,MACvBpC,GAAO,gCAAiCoB,KAAKC,UAAWS,GAAKnB,KAAKyB,KAAMzB,KAAKqB,IAE7ErB,KAAKyB,MAAQzB,KAAK0B,SACQ,IAArB1B,KAAK2B,cAES,iBADlBR,EAAInB,KAAK4B,WAAYT,IAGnBA,EADgB,IAAZnB,KAAKqB,GACLQ,EAAeV,GAEfU,EAAe7B,KAAK8B,KAAKX,GAEnBY,EAAUZ,GAChBnB,KAAKqB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe7B,KAAK8B,MAAQX,KAGlDrB,EAAM,IAAIoC,MAAOrD,EAAQ,QAASsC,KAG/BrB,EACJE,KAAKmC,KAAM,QAASrC,GAEpBoB,EAAMlB,KAAKuB,KAAMJ,EAElB,CAGF,IAiLAN,EAA0BpB,GAAmBwB,UAAW,WAxKxD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKrC,KAAKoB,YACT/B,GAAO,qDACAW,OAERqC,EAAOrC,KACPA,KAAKoB,YAAa,EAElBkB,GASA,WACMF,IACJ/C,GAAO,mDAAsDkD,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErB/C,GAAO,yBACPgD,EAAKF,KAAM,QACX,IAdMnC,KAiBR,IG/BAyC,EAAAC,GAAA,aAAA5D,IACA2D,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ec1f264..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1b38701 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From a6f85c4121f488fd1ae74b10d8f4b04a714317b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 20:05:30 +0000 Subject: [PATCH 044/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f619f63..ec1f264 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", From b2e001221142dbb10cc1a5676906156717c52fee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 20:06:00 +0000 Subject: [PATCH 045/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 3bf1250..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c141c95..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 68d7482..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;qjxDAwDA,SAASA,GAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,SACzBD,EAAKI,IAAMH,EAAQG,KACbC,EAAUL,EAAKI,MACb,IAAIE,UAAWC,EAAQ,QAAS,MAAOP,EAAKI,MAGhDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,cACzBD,EAAKU,SAAWT,EAAQS,UAClBL,EAAUL,EAAKU,WAAgC,OAAlBV,EAAKU,UAChC,IAAIJ,UAAWC,EAAQ,QAAS,WAAYP,EAAKU,WAGrDP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBC,EAAeZ,EAAKW,gBAClB,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,eACzBD,EAAKa,UAAYZ,EAAQY,WACnBC,EAAYd,EAAKa,YACf,IAAIP,UAAWC,EAAQ,QAAS,YAAaP,EAAKa,YAGpD,KAhCC,IAAIP,UAAWC,EAAQ,QAASN,GAiCzC,KChEIc,wDAAQC,CAAQ,6BCLhBC,GAAWC,GAA6BD,SA+J5C,SAASE,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQtB,GACvD,IAAID,EACAwB,EACAC,EACJ,KAAQC,gBAAgBP,IACvB,OAAKQ,UAAUC,OAAS,EAChB,IAAIT,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQtB,GAEpD,IAAIkB,GAAoBC,EAAGC,EAAQC,EAAQC,GAEnD,IAAMM,EAAsBT,GAC3B,MAAM,IAAId,UAAWC,EAAQ,QAASa,IAEvC,IAAMU,EAAcT,GACnB,MAAM,IAAIf,UAAWC,EAAQ,QAASc,IAEvC,IAAMU,EAAWT,GAChB,MAAM,IAAIhB,UAAWC,EAAQ,QAASe,IAEvC,IAAMO,EAAsBN,GAC3B,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAEvC,GAAKH,EAAI,IACRK,EAAIF,GAAWH,EAAE,GAAGE,EACfC,GAAUF,EAAOO,QAAUH,EAAI,GAAKA,GAAKJ,EAAOO,QACpD,MAAM,IAAII,WAAYzB,EAAQ,UAIhC,GADAP,EAAOiC,EAAMC,IACRP,UAAUC,OAAS,IACvBJ,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EA+BR,OA3BAT,GAAO,wEAAyEoB,KAAKC,UAAWpC,IAChGiB,GAASoB,KAAMX,KAAM1B,GAGrBsC,EAAkBZ,KAAM,cAAc,GAGtCa,EAA0Bb,KAAM,cAAe1B,EAAKQ,YAGpD+B,EAA0Bb,KAAM,OAAQ1B,EAAKI,KAG7CmC,EAA0Bb,KAAM,aAAc1B,EAAKa,WAAasB,KAAKC,WAGrEG,EAA0Bb,KAAM,UAAWL,GAG3CkB,EAA0Bb,KAAM,KAAMN,GACtCmB,EAA0Bb,KAAM,UAAWJ,GAC3CiB,EAA0Bb,KAAM,UAAWH,GAC3Ce,EAAkBZ,KAAM,OAAQH,GAGhCe,EAAkBZ,KAAM,KAAM,GAEvBA,IACR,CClLA,SAASlB,GAAYY,EAAGC,EAAQC,EAAQC,EAAQtB,GAC/C,IAAID,EACJ,GAAK2B,UAAUC,OAAS,EAAI,CAE3B,IAAM1B,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAOiC,EAAMhC,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIW,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQvB,EAC3D,CChBA,SAASwC,GAASvC,GACjB,IAAID,EAMJ,OAJCA,EADI2B,UAAUC,OACPK,EAAMhC,EAAS,GAEf,CAAA,EAEDwC,EAeP,SAASA,EAAcrB,EAAGC,EAAQC,EAAQC,GACzC,OAAO,IAAIJ,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQvB,EAC1D,CACF,CFiKA0C,EAASvB,GAAoBF,IAY7BsB,EAA0BpB,GAAmBwB,UAAW,SApNxD,WAEC,IAAIC,EACApB,EACAqB,EAEJ,IAAKnB,KAAKoB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHApB,EAAM,KAENE,KAAKqB,IAAM,EACNrB,KAAKqB,GAAKrB,KAAKsB,GAEnB,OADAjC,GAAO,uBACAW,KAAKuB,KAAM,MAEnBJ,EAAInB,KAAKwB,QAASxB,KAAKyB,MACvBpC,GAAO,gCAAiCoB,KAAKC,UAAWS,GAAKnB,KAAKyB,KAAMzB,KAAKqB,IAE7ErB,KAAKyB,MAAQzB,KAAK0B,SACQ,IAArB1B,KAAK2B,cAES,iBADlBR,EAAInB,KAAK4B,WAAYT,IAGnBA,EADgB,IAAZnB,KAAKqB,GACLQ,EAAeV,GAEfU,EAAe7B,KAAK8B,KAAKX,GAEnBY,EAAUZ,GAChBnB,KAAKqB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe7B,KAAK8B,MAAQX,KAGlDrB,EAAM,IAAIoC,MAAOrD,EAAQ,QAASsC,KAG/BrB,EACJE,KAAKmC,KAAM,QAASrC,GAEpBoB,EAAMlB,KAAKuB,KAAMJ,EAElB,CAGF,IAiLAN,EAA0BpB,GAAmBwB,UAAW,WAxKxD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKrC,KAAKoB,YACT/B,GAAO,qDACAW,OAERqC,EAAOrC,KACPA,KAAKoB,YAAa,EAElBkB,GASA,WACMF,IACJ/C,GAAO,mDAAsDkD,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErB/C,GAAO,yBACPgD,EAAKF,KAAM,QACX,IAdMnC,KAiBR,IG/BAyC,EAAAC,GAAA,aAAA5D,IACA2D,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1b38701..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From dd4d3d3df1a96530eabf70f58278940f6d1dfff6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 20:07:07 +0000 Subject: [PATCH 046/112] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 46 files changed, 6212 insertions(+), 6781 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index d1ed149..f10e815 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c141c95 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..68d7482 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ec1f264..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8a86d45 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 164be270bf12a5848690a9062e93e181c05f6f7f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 06:30:33 +0000 Subject: [PATCH 047/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4d93fc6..c95263b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = copy( DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 65a844c..2296922 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f619f63..ec1f264 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", From 25c980e2fa6ad19e356999dd37fa3c7889af8f44 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 14:55:33 +0000 Subject: [PATCH 048/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 f10e815..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c141c95..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 68d7482..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8a86d45..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0fe4f009a8a07e487ec383258ad337b74ea33557 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 14:56:34 +0000 Subject: [PATCH 049/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 47 files changed, 6212 insertions(+), 6782 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 8437250..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T04:10:13.234Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index d1ed149..f10e815 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c141c95 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..68d7482 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a71cefe..0000000 --- a/lib/factory.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 copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c95263b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = copy( DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 2296922..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ec1f264..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2e54d87 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From a3cad3a8fe2e83e3a9e9ef20f491a6b4f7599091 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:42:15 +0000 Subject: [PATCH 050/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62e2ca5..31739ca 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..7a1ee9d 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 2184166..122089a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", "@stdlib/object-assign": "github:stdlib-js/object-assign#main", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", From 6c73556d4950a8e997083430e75a12fddc89fd20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:44:37 +0000 Subject: [PATCH 051/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 f10e815..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c141c95..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s(pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s(i,1)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s(e,1):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 68d7482..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from '@stdlib/utils-copy';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = copy( options, 1 );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2e54d87..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 68d21b32f2043df5cbf9a61f830736da09b8213d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:45:46 +0000 Subject: [PATCH 052/112] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 46 files changed, 6212 insertions(+), 6781 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index d1ed149..f10e815 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..550fcd0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s({},i)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s({},e):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..70c9bd5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c081e82..0000000 --- a/lib/factory.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 assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 31739ca..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 7a1ee9d..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 122089a..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/object-assign": "github:stdlib-js/object-assign#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ab90c5d --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index a84f709..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 45dfef6..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 7279cd5..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index ea3c311..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 6f3c7fb..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 40074e2ff821f654be20b408a5c737e4ab425d30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 07:00:46 +0000 Subject: [PATCH 053/112] Transform error messages --- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62e2ca5..31739ca 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '0g2Au', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '0g22p', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '0g23A', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '0g23B', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '0g23C', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format( '0g21R' ) ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..7a1ee9d 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0g22h', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..00c8779 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0g22h', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '0g22i', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 2184166..122089a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.0.7", "@stdlib/buffer-from-string": "^0.0.8", "@stdlib/object-assign": "github:stdlib-js/object-assign#main", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-property": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", From bf4b126eba3ad3ceedadefcd2c7e46fd2e038966 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 15:36:47 +0000 Subject: [PATCH 054/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 f10e815..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 550fcd0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s({},i)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s({},e):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 70c9bd5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ab90c5d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c5de3d242373e8e6251c883d4b0669badc700eed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 15:37:43 +0000 Subject: [PATCH 055/112] 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 | 55 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 47 files changed, 6212 insertions(+), 6782 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 e32df40..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T04:35:00.024Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 0db22a7..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 88fb4c0..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: '41 5 * * 5' - - # 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 + + ```
@@ -262,7 +261,7 @@ stream.pipe( iStream ); ## 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]. @@ -330,7 +329,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index aafded9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index a0fb114..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ba47bb2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-unused-expression - -import StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index d1ed149..f10e815 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..550fcd0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s({},i)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s({},e):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..70c9bd5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c081e82..0000000 --- a/lib/factory.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 assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 31739ca..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '0g2Au', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '0g22p', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '0g23A', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '0g23B', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '0g23C', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format( '0g21R' ) ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 7a1ee9d..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0g22h', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 00c8779..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0g22h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0g22i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0g230', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0g284', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0g278', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 122089a..5f292a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-buffer": "^0.0.8", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/object-assign": "github:stdlib-js/object-assign#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "@stdlib/utils-next-tick": "^0.0.8", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.0.6", - "@stdlib/utils-parse-json": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d37b4a4 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 6846752541c4c5fe8a28dba3df667572e7c16a9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:40:23 +0000 Subject: [PATCH 056/112] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 37ba125..fe3265d 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.1.1", "@stdlib/buffer-from-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", From b3088c084ee77690c673e44cee285c634bed0c4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:57:48 +0000 Subject: [PATCH 057/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 f10e815..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/object'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; // tslint-disable-line max-line-length - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // tslint-disable-line max-line-length -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 550fcd0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=k(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function k(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C=[],O=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+C[i>>12&63]+C[i>>6&63]+C[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function H(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=J.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},J.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function we(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ve(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function me(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}J.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},J.prototype.readUInt8=function(e,t){return t||ye(e,1,this.length),this[e]},J.prototype.readUInt16LE=function(e,t){return t||ye(e,2,this.length),this[e]|this[e+1]<<8},J.prototype.readUInt16BE=function(e,t){return t||ye(e,2,this.length),this[e]<<8|this[e+1]},J.prototype.readUInt32LE=function(e,t){return t||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},J.prototype.readUInt32BE=function(e,t){return t||ye(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},J.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},J.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ye(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},J.prototype.readInt8=function(e,t){return t||ye(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},J.prototype.readInt16LE=function(e,t){t||ye(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt16BE=function(e,t){t||ye(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},J.prototype.readInt32LE=function(e,t){return t||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},J.prototype.readInt32BE=function(e,t){return t||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},J.prototype.readFloatLE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!0,23,4)},J.prototype.readFloatBE=function(e,t){return t||ye(e,4,this.length),Y(this,e,!1,23,4)},J.prototype.readDoubleLE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!0,52,8)},J.prototype.readDoubleBE=function(e,t){return t||ye(e,8,this.length),Y(this,e,!1,52,8)},J.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||we(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},J.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,255,0),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},J.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):me(this,e,t,!0),t+4},J.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},J.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);we(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},J.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,1,127,-128),J.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},J.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},J.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},J.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):me(this,e,t,!0),t+4},J.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||we(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),J.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):me(this,e,t,!1),t+4},J.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},J.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},J.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},J.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},J.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=O[e.charCodeAt(t)]<<2|O[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=O[e.charCodeAt(t)]<<10|O[e.charCodeAt(t+1)]<<4|O[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var ke=Me,Pe=xe;function Ce(e){if(ke===setTimeout)return setTimeout(e,0);if((ke===Me||!ke)&&setTimeout)return ke=setTimeout,setTimeout(e,0);try{return ke(e,0)}catch(t){try{return ke.call(null,e,0)}catch(t){return ke.call(this,e,0)}}}"function"==typeof P.setTimeout&&(ke=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Oe,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Oe&&(Ue=!1,Oe.length?Be=Oe.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Ce(Ie);Ue=!0;for(var t=Be.length;t;){for(Oe=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),mt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(yt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return yt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?yt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function yt(e){return wt(e)&&"[object RegExp]"===_t(e)}function wt(e){return"object"==typeof e&&null!==e}function vt(e){return wt(e)&&"[object Date]"===_t(e)}function mt(e){return wt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!wt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return J.alloc(0);if(1===this.length)return this.head.data;for(var t=J.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=J.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new J(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=kt;var xt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function kt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new kt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ct(e,t,r,n,i){var o=function(e,t){var r=null;J.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){xt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=J.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return xt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ot(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,xt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){xt("onunpipe"),e===r&&h()}function s(){xt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;xt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){xt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){xt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(xt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;xt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){xt("onfinish"),e.removeListener("close",d),g()}function g(){xt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(xt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Gt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Gt.prototype._writev=null,Gt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys(Gt.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),wr=dr.Readable;function vr(r,n,a,h,f){var c,d,p;if(!(this instanceof vr))return arguments.length>4?new vr(r,n,a,h,f):new vr(r,n,a,h);if(!o(r))throw new TypeError(l("0g22p",r));if(!t(n))throw new TypeError(l("0g23A",n));if(!i(a))throw new TypeError(l("0g23B",a));if(!o(h))throw new TypeError(l("0g23C",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError(l("0g21R"));if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return yr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),wr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function mr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("0g22h",o));o=s({},i)}else o={};return o.objectMode=!0,new vr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s({},e):{},r;function r(e,r,n,i){return new vr(e,r,n,i,t)}}a(vr,wr),e(vr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return yr("Finished iteration."),this.push(null);r=this._buffer[this._idx],yr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("0g2Au",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(yr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(yr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));yr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",mr),e(vr,"factory",br);export{vr as default,br as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 70c9bd5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0g22h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '0g22i', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '0g230', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '0g284', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '0g24x', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '0g278', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '0g2Au', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '0g22p', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '0g23A', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '0g23B', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '0g23C', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format( '0g21R' ) );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0g22h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d37b4a4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e08bcca85c04e5ccbdad850af9ed798f7d776aca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:58:17 +0000 Subject: [PATCH 058/112] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 95 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 53 files changed, 6212 insertions(+), 6925 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 c23f33c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:51:50.034Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d162150..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: '41 5 * * 5' - - # 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 + + ```
@@ -273,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -341,7 +340,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 46845e3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(le,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(he,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ve,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(ge,O){ -var S=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=y(i):i=y(this._sep+i):L(i)?this._i>1&&(i=H.concat([y(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ee('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),S.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,S);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);O.exports=u -});var T=o(function(ce,x){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}x.exports=te -});var k=o(function(me,z){ -var ae=require('@stdlib/object-assign/dist'),ne=c();function se(e){var r;return arguments.length?r=ae({},e):r={},i;function i(a,s,t,h){return new ne(a,s,t,h,r)}}z.exports=se -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=c(),ue=T(),oe=k();V(b,"objectMode",ue);V(b,"factory",oe);module.exports=b; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 80ff91f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index cbb9908..4d7eea7 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d28b543 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+O[i>>12&63]+O[i>>6&63]+O[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=O[t>>2],i+=O[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=O[t>>10],i+=O[t>>4&63],i+=O[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Pe=ke;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof P.setTimeout&&(xe=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Oe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ot(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s({},e):{},r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..810e8bf --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c081e82..0000000 --- a/lib/factory.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 assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 62e2ca5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index c0c7043..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 2f4fce4..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fe3265d..581687e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "@stdlib/utils-next-tick": "^0.1.1", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/streams-node-inspect-sink": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8939358 --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 8f2b627342c4424516e9950cf793814114026be7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Jan 2024 23:22:50 +0000 Subject: [PATCH 059/112] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 37ba125..fe3265d 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.1.1", "@stdlib/buffer-from-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", From b4c25dbce12b785e769d0876f99b6a203e345875 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Jan 2024 23:23:42 +0000 Subject: [PATCH 060/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 4d7eea7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d28b543..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:A(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+O[i>>12&63]+O[i>>6&63]+O[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=O[t>>2],i+=O[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=O[t>>10],i+=O[t>>4&63],i+=O[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ae(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ae(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Le(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Te(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Pe=ke;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof P.setTimeout&&(xe=setTimeout),"function"==typeof P.clearTimeout&&(Pe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Oe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function At(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Tt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=Lt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Lt(e){return e.toString(this.encoding)}function Tt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}At.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},At.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},At.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Pt.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new At(e.encoding),this.encoding=e.encoding)}function Pt(e){if(!(this instanceof Pt))return new Pt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Ot(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Pt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Pt.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Pt.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Pt);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;return t=arguments.length?s({},e):{},r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 810e8bf..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8939358..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b8f2413683aa5e1894bd07139ab882b3906423dd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Jan 2024 23:24:01 +0000 Subject: [PATCH 061/112] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 52 files changed, 6212 insertions(+), 6930 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d162150..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: '41 5 * * 5' - - # 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 + + ```
@@ -273,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -341,7 +340,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 70be45f..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1344251..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ce,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(me,S){ -var O=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ne('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u -});var x=o(function(fe,T){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te -});var k=o(function(be,z){ -var ae=require('@stdlib/assert-is-plain-object/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist'),se=require('@stdlib/object-assign/dist'),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne('1MH2V',e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5d3257 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:T(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+P[i>>12&63]+P[i>>6&63]+P[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=P[t>>2],i+=P[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=P[t>>10],i+=P[t>>4&63],i+=P[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Te(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Te(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ae(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Le(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Oe=ke;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof O.setTimeout&&(xe=setTimeout),"function"==typeof O.clearTimeout&&(Oe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Pe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Tt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Lt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=At)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function At(e){return e.toString(this.encoding)}function Lt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Tt.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},Tt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Tt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Ot.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Tt(e.encoding),this.encoding=e.encoding)}function Ot(e){if(!(this instanceof Ot))return new Ot(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Pt(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Ot.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ot.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Ot.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Ot);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f4302fa --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index b19b1f9..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 62e2ca5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index c0c7043..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 2f4fce4..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fe3265d..581687e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "@stdlib/utils-next-tick": "^0.1.1", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/streams-node-inspect-sink": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..216cbcc --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 7c89ab1fb88927bcd9d0efb4394e331bad55873b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 05:07:56 +0000 Subject: [PATCH 062/112] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 37ba125..fe3265d 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.1.1", "@stdlib/buffer-from-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", From b54de3fea1845ed2905e9991797a69b90440ebd8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:23:00 +0000 Subject: [PATCH 063/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5d3257..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:T(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+P[i>>12&63]+P[i>>6&63]+P[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=P[t>>2],i+=P[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=P[t>>10],i+=P[t>>4&63],i+=P[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Te(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Te(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ae(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Le(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Oe=ke;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof O.setTimeout&&(xe=setTimeout),"function"==typeof O.clearTimeout&&(Oe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Pe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Tt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Lt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=At)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function At(e){return e.toString(this.encoding)}function Lt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Tt.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},Tt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Tt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Ot.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Tt(e.encoding),this.encoding=e.encoding)}function Ot(e){if(!(this instanceof Ot))return new Ot(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Pt(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Ot.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ot.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Ot.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Ot);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f4302fa..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 216cbcc..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b2bb6cf0bc35d4301a6b29de7aa9cf58b88b9bce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:23:35 +0000 Subject: [PATCH 064/112] 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 | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 53 files changed, 6212 insertions(+), 6936 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 580e678..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T03:27:05.297Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d162150..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1344251..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ce,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(me,S){ -var O=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ne('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u -});var x=o(function(fe,T){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te -});var k=o(function(be,z){ -var ae=require('@stdlib/assert-is-plain-object/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist'),se=require('@stdlib/object-assign/dist'),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne('1MH2V',e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5d3257 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:T(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+P[i>>12&63]+P[i>>6&63]+P[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=P[t>>2],i+=P[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=P[t>>10],i+=P[t>>4&63],i+=P[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Te(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Te(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ae(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Le(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Oe=ke;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof O.setTimeout&&(xe=setTimeout),"function"==typeof O.clearTimeout&&(Oe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Pe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Tt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Lt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=At)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function At(e){return e.toString(this.encoding)}function Lt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Tt.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},Tt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Tt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Ot.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Tt(e.encoding),this.encoding=e.encoding)}function Ot(e){if(!(this instanceof Ot))return new Ot(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Pt(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Ot.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ot.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Ot.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Ot);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f4302fa --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index b19b1f9..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 62e2ca5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index c0c7043..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 2f4fce4..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fe3265d..581687e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "@stdlib/utils-next-tick": "^0.1.1", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/streams-node-inspect-sink": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..52a17cb --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 29289dc213e04f1eae7e5b49cda4d97d3cd8b2b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 09:04:15 +0000 Subject: [PATCH 065/112] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 00825d1..dd7d86f 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.0", "@stdlib/buffer-from-string": "^0.2.0", "@stdlib/object-assign": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1", "@stdlib/utils-define-nonenumerable-property": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", From bcd4a7c64f7a38b1f757aaa4088a01d81bc0ec5e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 17:49:36 +0000 Subject: [PATCH 066/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5d3257..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:T(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+P[i>>12&63]+P[i>>6&63]+P[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=P[t>>2],i+=P[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=P[t>>10],i+=P[t>>4&63],i+=P[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Te(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Te(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ae(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Le(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Oe=ke;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof O.setTimeout&&(xe=setTimeout),"function"==typeof O.clearTimeout&&(Oe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Pe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Tt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Lt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=At)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function At(e){return e.toString(this.encoding)}function Lt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Tt.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},Tt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Tt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Ot.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Tt(e.encoding),this.encoding=e.encoding)}function Ot(e){if(!(this instanceof Ot))return new Ot(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Pt(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Ot.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ot.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Ot.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Ot);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f4302fa..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 52a17cb..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d27fc0a60d30156fa236259bb2cffd4df0f6db78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 17:50:40 +0000 Subject: [PATCH 067/112] 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 | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 52 files changed, 6212 insertions(+), 6939 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 36f0935..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1344251..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ce,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(me,S){ -var O=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ne('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u -});var x=o(function(fe,T){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te -});var k=o(function(be,z){ -var ae=require('@stdlib/assert-is-plain-object/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist'),se=require('@stdlib/object-assign/dist'),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne('1MH2V',e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..be36cdc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.0-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.0-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:T(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+P[i>>12&63]+P[i>>6&63]+P[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=P[t>>2],i+=P[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=P[t>>10],i+=P[t>>4&63],i+=P[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Te(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Te(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ae(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Le(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Oe=ke;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof O.setTimeout&&(xe=setTimeout),"function"==typeof O.clearTimeout&&(Oe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Pe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Tt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Lt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=At)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function At(e){return e.toString(this.encoding)}function Lt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Tt.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},Tt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Tt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Ot.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Tt(e.encoding),this.encoding=e.encoding)}function Ot(e){if(!(this instanceof Ot))return new Ot(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Pt(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Ot.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ot.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Ot.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Ot);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f4302fa --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index b19b1f9..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 62e2ca5..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index c0c7043..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 2f4fce4..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index dd7d86f..3408a2d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.2.0", - "@stdlib/assert-is-buffer": "^0.2.0", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/assert-is-error": "^0.2.0", - "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/assert-is-integer": "^0.2.0", - "@stdlib/assert-is-nonnegative-integer": "^0.2.0", - "@stdlib/assert-is-nonnegative-number": "^0.2.0", - "@stdlib/assert-is-plain-object": "^0.2.0", - "@stdlib/assert-is-string": "^0.2.0", - "@stdlib/buffer-ctor": "^0.2.0", - "@stdlib/buffer-from-string": "^0.2.0", - "@stdlib/object-assign": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-property": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/utils-inherit": "^0.2.0", - "@stdlib/utils-next-tick": "^0.2.0", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/streams-node-inspect-sink": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70c6abe --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From b1d7906d026f81078d91607cef9ca3859a8cba04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:04:09 +0000 Subject: [PATCH 068/112] Update README.md for ESM bundle v0.2.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b45ad72..c86ff02 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.0-esm/index.mjs'; ``` @@ -211,7 +211,7 @@ This method accepts the same `options` as [`stridedArrayStream()`](#strided-arra import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.0-esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 137b66fba80ff80ce100fdec7555a31150b5171a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:04:10 +0000 Subject: [PATCH 069/112] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c86ff02..2a5a74a 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@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/streams-node-from-strided-array/tags). For example, + ```javascript import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.0-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-no You can also import the following named exports from the package: ```javascript -import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.0-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; ``` @@ -211,7 +216,7 @@ This method accepts the same `options` as [`stridedArrayStream()`](#strided-arra import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.0-esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 93c0dc08d52506b015835be29c8f5796c5ecb584 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 16:40:42 +0000 Subject: [PATCH 070/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index b1325df..16403c1 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.1", "@stdlib/buffer-from-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-property": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", From 047d57cc188cd32df4cb1ac1f4b62cd1c468d76f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:33:08 +0000 Subject: [PATCH 071/112] Remove files --- index.d.ts | 305 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6487 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index be36cdc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.0-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.0-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r){if(t)e.call(r);else for(var n=e.length,i=x(e,n),o=0;o0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function M(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function k(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function x(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:R(r,f,this);break;case 2:j(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:T(r,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,U=!1;function D(){U=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+P[i>>12&63]+P[i>>6&63]+P[63&i]);return o.join("")}function z(e){var t;U||D();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=P[t>>2],i+=P[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=P[t>>10],i+=P[t>>4&63],i+=P[t<<2&63],i+="="),o.push(i),o.join("")}function Y(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function N(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var W={}.toString,q=Array.isArray||function(e){return"[object Array]"==W.call(e)};function F(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(e,t){if(F()=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|e}function Q(e){return!(null==e||!e._isBuffer)}function X(e,t){if(Q(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Se(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Te(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function ee(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return pe(this,t,r);case"utf8":case"utf-8":return le(this,t,r);case"ascii":return ce(this,t,r);case"latin1":case"binary":return de(this,t,r);case"base64":return fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function te(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=H.from(t,n)),Q(t))return 0===t.length?-1:ne(e,t,r,n,i);if("number"==typeof t)return t&=255,H.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function fe(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function le(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},H.prototype.compare=function(e,t,r,n,i){if(!Q(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ie(this,e,t,r);case"utf8":case"utf-8":return oe(this,e,t,r);case"ascii":return se(this,e,t,r);case"latin1":case"binary":return ae(this,e,t,r);case"base64":return ue(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ce(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,o){if(!Q(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function we(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function be(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _e(e,t,r,n,i){return i||be(e,0,r,4),N(e,t,r,n,23,4),r+4}function Ee(e,t,r,n,i){return i||be(e,0,r,8),N(e,t,r,n,52,8),r+8}H.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},H.prototype.readUInt8=function(e,t){return t||ve(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ve(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ve(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},H.prototype.readUInt32BE=function(e,t){return t||ve(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},H.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},H.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ve(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},H.prototype.readInt8=function(e,t){return t||ve(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ve(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt16BE=function(e,t){t||ve(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},H.prototype.readInt32LE=function(e,t){return t||ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},H.prototype.readInt32BE=function(e,t){return t||ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},H.prototype.readFloatLE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ve(e,4,this.length),Y(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ve(e,8,this.length),Y(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||me(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},H.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},H.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):we(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},H.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);me(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},H.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},H.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ye(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ye(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):we(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||me(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):we(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return _e(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)},H.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!H.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Te(e){return function(e){var t,r,n,i,o,s;U||D();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=C[e.charCodeAt(t)]<<2|C[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=C[e.charCodeAt(t)]<<10|C[e.charCodeAt(t+1)]<<4|C[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Re,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ae(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Le(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Me(){throw new Error("setTimeout has not been defined")}function ke(){throw new Error("clearTimeout has not been defined")}var xe=Me,Oe=ke;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Me||!xe)&&setTimeout)return xe=setTimeout,setTimeout(e,0);try{return xe(e,0)}catch(t){try{return xe.call(null,e,0)}catch(t){return xe.call(this,e,0)}}}"function"==typeof O.setTimeout&&(xe=setTimeout),"function"==typeof O.clearTimeout&&(Oe=clearTimeout);var Ce,Be=[],Ue=!1,De=-1;function Ie(){Ue&&Ce&&(Ue=!1,Ce.length?Be=Ce.concat(Be):De=-1,Be.length&&ze())}function ze(){if(!Ue){var e=Pe(Ie);Ue=!0;for(var t=Be.length;t;){for(Ce=Be,Be=[];++De1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ct(t)?r.showHidden=t:t&&Et(r,t),gt(r.showHidden)&&(r.showHidden=!1),gt(r.depth)&&(r.depth=2),gt(r.colors)&&(r.colors=!1),gt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=at),ht(r,e,r.depth)}function at(e,t){var r=st.styles[t];return r?"["+st.colors[r][0]+"m"+e+"["+st.colors[r][1]+"m":e}function ut(e,t){return e}function ht(e,t,r){if(e.customInspect&&t&&bt(t.inspect)&&t.inspect!==st&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return pt(n)||(n=ht(e,n,r)),n}var i=function(e,t){if(gt(t))return e.stylize("undefined","undefined");if(pt(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ct(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),wt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ft(t);if(0===o.length){if(bt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(vt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ft(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),bt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return vt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ft(t)),0!==o.length||l&&0!=t.length?r<0?vt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function ft(e){return"["+Error.prototype.toString.call(e)+"]"}function lt(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),Rt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=dt(r)?ht(e,u.value,null):ht(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),gt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ct(e){return"boolean"==typeof e}function dt(e){return null===e}function pt(e){return"string"==typeof e}function gt(e){return void 0===e}function vt(e){return mt(e)&&"[object RegExp]"===_t(e)}function mt(e){return"object"==typeof e&&null!==e}function yt(e){return mt(e)&&"[object Date]"===_t(e)}function wt(e){return mt(e)&&("[object Error]"===_t(e)||e instanceof Error)}function bt(e){return"function"==typeof e}function _t(e){return Object.prototype.toString.call(e)}function Et(e,t){if(!t||!mt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Rt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jt(){this.head=null,this.tail=null,this.length=0}st.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},st.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},jt.prototype.concat=function(e){if(0===this.length)return H.alloc(0);if(1===this.length)return this.head.data;for(var t=H.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var St=H.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Tt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!St(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Lt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Mt;break;default:return void(this.write=At)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function At(e){return e.toString(this.encoding)}function Lt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Tt.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},Tt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Tt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Ot.ReadableState=xt;var kt=function(e){if(gt(it)&&(it=Xe.env.NODE_DEBUG||""),e=e.toUpperCase(),!ot[e])if(new RegExp("\\b"+e+"\\b","i").test(it)){ot[e]=function(){var t=rt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else ot[e]=function(){};return ot[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof or&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new jt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Tt(e.encoding),this.encoding=e.encoding)}function Ot(e){if(!(this instanceof Ot))return new Ot(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Pt(e,t,r,n,i){var o=function(e,t){var r=null;H.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Bt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ye(Dt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(kt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ye(Ut,e):Ut(e))}function Ut(e){kt("emit readable"),e.emit("readable"),Yt(e)}function Dt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=H.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Wt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ye(qt,t,e))}function qt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ft(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return kt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Wt(this):Bt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Wt(this),null;var n,i=t.needReadable;return kt("need readable",i),(0===t.length||t.length-e0?Nt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Wt(this)),null!==n&&this.emit("data",n),n},Ot.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ot.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,kt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){kt("onunpipe"),e===r&&h()}function s(){kt("onend"),e.end()}n.endEmitted?Ye(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;kt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Yt(e))}}(r);e.on("drain",a);var u=!1;function h(){kt("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){kt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Ft(n.pipes,e))&&!u&&(kt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;kt("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){kt("onfinish"),e.removeListener("close",d),g()}function g(){kt("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(kt("pipe resume"),r.resume()),e},Ot.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},$t.prototype._write=function(e,t,r){r(new Error("not implemented"))},$t.prototype._writev=null,$t.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,er(e,t),r&&(t.finished?Ye(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},et(or,Ot);for(var rr=Object.keys($t.prototype),nr=0;nr()=>{}}))("from-strided-array-stream"),mr=dr.Readable;function yr(r,n,a,h,f){var c,d,p;if(!(this instanceof yr))return arguments.length>4?new yr(r,n,a,h,f):new yr(r,n,a,h);if(!o(r))throw new TypeError(l("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(!t(n))throw new TypeError(l("invalid argument. Second argument must be an array-like object. Value: `%s`.",n));if(!i(a))throw new TypeError(l("invalid argument. Third argument must be an integer. Value: `%s`.",a));if(!o(h))throw new TypeError(l("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",h));if(r>0&&(p=h+(r-1)*a,h>=n.length||p<0||p>=n.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(c=s({},pr),arguments.length>4&&(d=gr(c,f)))throw d;return vr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),mr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function wr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",o));o=s({},i)}else o={};return o.objectMode=!0,new yr(e,t,r,n,o)}function br(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return r;function r(e,r,n,i){return new yr(e,r,n,i,t)}}a(yr,mr),e(yr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return vr("Finished iteration."),this.push(null);r=this._buffer[this._idx],vr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),e(yr.prototype,"destroy",(function(e){var t;return this._destroyed?(vr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(vr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));vr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",wr),e(yr,"factory",br);export{yr as default,br as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f4302fa..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/debug.js","../lib/main.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/string-format';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["validate","opts","options","isObject","hasOwnProp","sep","isString","TypeError","format","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","err","i","this","arguments","length","isNonNegativeInteger","isCollection","isInteger","RangeError","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70c6abe..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 22a0b3e1c8d4e6e327406c66b5f3aa8aaf1df413 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:39:32 +0000 Subject: [PATCH 072/112] 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 | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 52 files changed, 4877 insertions(+), 6933 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1344251..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ce,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(me,S){ -var O=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ne('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u -});var x=o(function(fe,T){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te -});var k=o(function(be,z){ -var ae=require('@stdlib/assert-is-plain-object/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist'),se=require('@stdlib/object-assign/dist'),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne('1MH2V',e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7372e6a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 16403c1..944730a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-number": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/object-assign": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-property": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.0", - "@stdlib/streams-node-inspect-sink": "^0.2.0", - "@stdlib/utils-parse-json": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..82b04cb --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 724b4d438f6405c6793ec682f082229aa001e0bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 19:13:10 +0000 Subject: [PATCH 073/112] Update README.md for ESM bundle v0.2.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4acca06..26647fc 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.1-esm/index.mjs'; ``` @@ -211,7 +211,7 @@ This method accepts the same `options` as [`stridedArrayStream()`](#strided-arra import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.1-esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 1adb25a3d91c0b01de2f802cdf208b226f62150f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 19:13:10 +0000 Subject: [PATCH 074/112] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26647fc..b662787 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@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/streams-node-from-strided-array/tags). For example, + ```javascript import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.1-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-no You can also import the following named exports from the package: ```javascript -import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.1-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; ``` @@ -211,7 +216,7 @@ This method accepts the same `options` as [`stridedArrayStream()`](#strided-arra import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.1-esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 515ed53cf996a88486fb8ead79fe917d124cd052 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 04:38:37 +0000 Subject: [PATCH 075/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 06dbb7f..4fc4cc7 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.1", "@stdlib/buffer-from-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-property": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", From 80764dd33c0e1ba0d31b8b1795a7b5f05c90b1a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 09:05:33 +0000 Subject: [PATCH 076/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7372e6a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 82b04cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c7f6d888039bcf9fc6bf118e5d66dca705c8a1a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 09:05:47 +0000 Subject: [PATCH 077/112] 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 | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 53 files changed, 4877 insertions(+), 6936 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 c478398..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T03:22:00.882Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1344251..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ce,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(me,S){ -var O=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ne('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u -});var x=o(function(fe,T){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te -});var k=o(function(be,z){ -var ae=require('@stdlib/assert-is-plain-object/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist'),se=require('@stdlib/object-assign/dist'),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne('1MH2V',e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5dafd23 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 4fc4cc7..944730a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-number": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/object-assign": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-property": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..66077ce --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 435fd5e9bcb3662ec6cb94bdc30ce9ec9bbc1cec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 04:06:57 +0000 Subject: [PATCH 078/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 06dbb7f..4fc4cc7 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.1", "@stdlib/buffer-from-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-property": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", From 9d07d39e2f970db66f3c4bca0a79b7eb003d8b1c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:45:21 +0000 Subject: [PATCH 079/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5dafd23..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 66077ce..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4130620d815aa3d89bedb42da6c2ff27a41ea6f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:45:35 +0000 Subject: [PATCH 080/112] 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 | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 53 files changed, 4877 insertions(+), 6939 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 84bc209..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:45:29.284Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1344251..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ce,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(me,S){ -var O=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ne('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u -});var x=o(function(fe,T){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te -});var k=o(function(be,z){ -var ae=require('@stdlib/assert-is-plain-object/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist'),se=require('@stdlib/object-assign/dist'),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne('1MH2V',e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5dafd23 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 4fc4cc7..944730a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-number": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/object-assign": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-property": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..66077ce --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 32002c900a3a02ed41893880c9eb5cf8bd06e6cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 00:17:43 +0000 Subject: [PATCH 081/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index 06dbb7f..4fc4cc7 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.1", "@stdlib/buffer-from-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-property": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", From 3df5c02606531bdcb13933493c7fa9c0d8eea857 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:24:33 +0000 Subject: [PATCH 082/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5dafd23..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 66077ce..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c05de22abfe33e483008b81947bbbc20fee66397 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:24:52 +0000 Subject: [PATCH 083/112] 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 | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 52 files changed, 4877 insertions(+), 6940 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1344251..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){ -var N=require('@stdlib/assert-is-plain-object/dist'),v=require('@stdlib/assert-has-own-property/dist'),P=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,p=require('@stdlib/assert-is-string/dist').isPrimitive,A=require('@stdlib/assert-is-function/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d('1MH2W',"sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d('1MH2o',"objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d('1MH7n',"encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d('1MH4k',"highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d('1MH6p',"serialize",e.serialize)):null:new TypeError(d('1MH2V',r));}w.exports=R -});var M=o(function(ce,j){ -var B=require("debug"),I=B("from-strided-array-stream");j.exports=I -});var c=o(function(me,S){ -var O=require("readable-stream").Readable,J=require('@stdlib/assert-is-collection/dist'),C=require('@stdlib/assert-is-error/dist'),L=require('@stdlib/assert-is-buffer/dist'),D=require('@stdlib/assert-is-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,G=require('@stdlib/object-assign/dist'),U=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),n=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=require('@stdlib/buffer-from-string/dist'),H=require('@stdlib/buffer-ctor/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=require('@stdlib/utils-next-tick/dist'),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g('1MHA9',i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g('1MH2d',e));if(!J(r))throw new TypeError(g('1MH2y',r));if(!D(i))throw new TypeError(g('1MH2z',i));if(!E(a))throw new TypeError(g('1MH30',a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError(ne('1MH1K'));if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u -});var x=o(function(fe,T){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee('1MH2V',t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te -});var k=o(function(be,z){ -var ae=require('@stdlib/assert-is-plain-object/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist'),se=require('@stdlib/object-assign/dist'),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne('1MH2V',e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe -});var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5dafd23 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;goxDA2BIA,wDAAQC,CAAQ,6BCLhBC,GAAWC,GAA6BD,SA+J5C,SAASE,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQC,GACvD,IAAIC,EACAC,EACAC,EACJ,KAAQC,gBAAgBT,IACvB,OAAKU,UAAUC,OAAS,EAChB,IAAIX,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQC,GAEpD,IAAIL,GAAoBC,EAAGC,EAAQC,EAAQC,GAEnD,IAAMQ,EAAsBX,GAC3B,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAEvC,IAAMS,EAAsBR,GAC3B,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAKH,EAAI,IACRO,EAAIJ,GAAWH,EAAE,GAAGE,EACfC,GAAUF,EAAOS,QAAUH,EAAI,GAAKA,GAAKN,EAAOS,QACpD,MAAM,IAAIM,WAAYH,EAAO,UAI/B,GADAR,EAAOY,EAAQ,GAAIC,IACdT,UAAUC,OAAS,IACvBJ,EC3JF,SAAmBD,EAAMD,GACxB,OAAMe,EAAUf,GAGXgB,EAAYhB,EAAS,SACzBC,EAAKgB,IAAMjB,EAAQiB,KACbC,EAAUjB,EAAKgB,MACb,IAAIT,UAAWC,EAAQ,QAAS,MAAOR,EAAKgB,MAGhDD,EAAYhB,EAAS,gBACzBC,EAAKkB,WAAanB,EAAQmB,YACpBC,EAAWnB,EAAKkB,aACd,IAAIX,UAAWC,EAAQ,QAAS,aAAcR,EAAKkB,aAGvDH,EAAYhB,EAAS,cACzBC,EAAKoB,SAAWrB,EAAQqB,UAClBH,EAAUjB,EAAKoB,WAAgC,OAAlBpB,EAAKoB,UAChC,IAAIb,UAAWC,EAAQ,QAAS,WAAYR,EAAKoB,WAGrDL,EAAYhB,EAAS,mBACzBC,EAAKqB,cAAgBtB,EAAQsB,eACvBC,EAAetB,EAAKqB,gBAClB,IAAId,UAAWC,EAAQ,QAAS,gBAAiBR,EAAKqB,gBAG1DN,EAAYhB,EAAS,eACzBC,EAAKuB,UAAYxB,EAAQwB,WACnBC,EAAYxB,EAAKuB,YACf,IAAIhB,UAAWC,EAAQ,QAAS,YAAaR,EAAKuB,YAGpD,KAhCC,IAAIhB,UAAWC,EAAQ,QAAST,GAiCzC,CDwHQ0B,CAAUzB,EAAMD,GACjBE,GACJ,MAAMA,EA+BR,OA3BAX,GAAO,wEAAyEoC,KAAKC,UAAW3B,IAChGR,GAASoC,KAAMzB,KAAMH,GAGrB6B,EAAkB1B,KAAM,cAAc,GAGtC2B,EAA0B3B,KAAM,cAAeH,EAAKkB,YAGpDY,EAA0B3B,KAAM,OAAQH,EAAKgB,KAG7Cc,EAA0B3B,KAAM,aAAcH,EAAKuB,WAAaG,KAAKC,WAGrEG,EAA0B3B,KAAM,UAAWP,GAG3CkC,EAA0B3B,KAAM,KAAMR,GACtCmC,EAA0B3B,KAAM,UAAWN,GAC3CiC,EAA0B3B,KAAM,UAAWL,GAC3C+B,EAAkB1B,KAAM,OAAQL,GAGhC+B,EAAkB1B,KAAM,KAAM,GAEvBA,IACR,CElLA,SAASe,GAAYvB,EAAGC,EAAQC,EAAQC,EAAQC,GAC/C,IAAIC,EACJ,GAAKI,UAAUC,OAAS,EAAI,CAE3B,IAAMS,EADNd,EAAOD,GAEN,MAAM,IAAIQ,UAAWC,EAAQ,QAASR,IAEvCA,EAAOY,EAAQ,GAAIb,EACrB,MACEC,EAAO,CAAA,EAGR,OADAA,EAAKkB,YAAa,EACX,IAAIxB,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQE,EAC3D,CCbA,SAAS+B,GAAShC,GACjB,IAAIC,EACJ,GAAKI,UAAUC,OAAS,CACvB,IAAMS,EAAUf,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvCC,EAAOY,EAAQ,GAAIb,EACrB,MACEC,EAAO,CAAA,EAER,OAeA,SAAuBL,EAAGC,EAAQC,EAAQC,GACzC,OAAO,IAAIJ,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQE,EAC1D,CACF,CH2JAgC,EAAStC,GAAoBF,IAY7BsC,EAA0BpC,GAAmBuC,UAAW,SApNxD,WAEC,IAAIC,EACAjC,EACAkC,EAEJ,IAAKhC,KAAKiC,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAjC,EAAM,KAENE,KAAKkC,IAAM,EACNlC,KAAKkC,GAAKlC,KAAKmC,GAEnB,OADAhD,GAAO,uBACAa,KAAKoC,KAAM,MAEnBJ,EAAIhC,KAAKqC,QAASrC,KAAKsC,MACvBnD,GAAO,gCAAiCoC,KAAKC,UAAWQ,GAAKhC,KAAKsC,KAAMtC,KAAKkC,IAE7ElC,KAAKsC,MAAQtC,KAAKuC,SACQ,IAArBvC,KAAKwC,cAES,iBADlBR,EAAIhC,KAAKyC,WAAYT,IAGnBA,EADgB,IAAZhC,KAAKkC,GACLQ,EAAeV,GAEfU,EAAe1C,KAAK2C,KAAKX,GAEnBY,EAAUZ,GAChBhC,KAAKkC,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1C,KAAK2C,MAAQX,KAGlDlC,EAAM,IAAIiD,MAAO1C,EAAQ,QAAS2B,KAG/BlC,EACJE,KAAKgD,KAAM,QAASlD,GAEpBiC,EAAM/B,KAAKoC,KAAMJ,EAElB,CAGF,IAiLAL,EAA0BpC,GAAmBuC,UAAW,WAxKxD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlD,KAAKiC,YACT9C,GAAO,qDACAa,OAERkD,EAAOlD,KACPA,KAAKiC,YAAa,EAElBkB,GASA,WACMF,IACJ9D,GAAO,mDAAsDiE,EAASH,GAAYA,EAAMI,QAAU9B,KAAKC,UAAWyB,IAClHC,EAAKF,KAAM,QAASC,IAErB9D,GAAO,yBACP+D,EAAKF,KAAM,QACX,IAdMhD,KAiBR,II/BAsD,EAAAC,GAAA,aAAAxC,IACAuC,EAAAC,GAAA,UAAA3B"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 4fc4cc7..944730a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-nonnegative-number": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/object-assign": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-property": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..66077ce --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 23a9419678dbddc4f0495dd7047ace8eddbb9c5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:28:03 +0000 Subject: [PATCH 084/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index b3b0028..ff21cf5 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From ea74cca615cd0b8cf077fa4b05cca446544b324f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:35:25 +0000 Subject: [PATCH 085/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5dafd23..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 66077ce..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 91efeb9e17e6494627159b927fc6bfac948e1560 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:35:46 +0000 Subject: [PATCH 086/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 52 files changed, 4877 insertions(+), 7152 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ff21cf5..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From d20326ebd7af2d8c5520f5b1ce6208283fdbdb95 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:38:07 +0000 Subject: [PATCH 087/112] Update README.md for ESM bundle v0.2.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8ae3ea..6c3c228 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.2-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.2-esm/index.mjs'; ``` @@ -211,7 +211,7 @@ This method accepts the same `options` as [`stridedArrayStream()`](#strided-arra import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.2-esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 98541565df63d2fc6d1db69ccc7625ef2eb04258 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:38:08 +0000 Subject: [PATCH 088/112] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c3c228..e5dd6bb 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@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/streams-node-from-strided-array/tags). For example, + ```javascript import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.2-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-no You can also import the following named exports from the package: ```javascript -import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.2-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; ``` @@ -211,7 +216,7 @@ This method accepts the same `options` as [`stridedArrayStream()`](#strided-arra import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; -import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@v0.2.2-esm/index.mjs'; +import stridedArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-strided-array@esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 3b8ce017ddd63830e3d8e10d10df781404d33453 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 04:41:42 +0000 Subject: [PATCH 089/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index b362586..4f08b68 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 98ff834fb6fc6b24a84f250523a6b4f3b7a7461e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:47:18 +0000 Subject: [PATCH 090/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3d23555208215535b6829a0cb25f89eac44e23c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:47:34 +0000 Subject: [PATCH 091/112] 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 | 138 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 53 files changed, 4877 insertions(+), 7093 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 da58a48..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T03:22:24.435Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 4f08b68..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From f17324c945b62e95e92da66d4e96dba473c91915 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:35:14 +0000 Subject: [PATCH 092/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index b362586..4f08b68 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 46e86f38d8900e1f02fc08f213ed7475d2031631 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:48:11 +0000 Subject: [PATCH 093/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1ec54cead043524a01d4ffa5aad0b60341d03c0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:48:31 +0000 Subject: [PATCH 094/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 53 files changed, 4877 insertions(+), 7155 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 7d9903a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T18:32:48.560Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 4f08b68..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 0b30e46fe8883493f717804ea283134651b4832b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 04:50:45 +0000 Subject: [PATCH 095/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f3a638b..48edb18 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 4967ef7749e53984f0821cf53588d82dc492aa6c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:50:17 +0000 Subject: [PATCH 096/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 380181e509b381a99a47f5c392a1282919a1cfed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:50:32 +0000 Subject: [PATCH 097/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 53 files changed, 4877 insertions(+), 7155 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 dbb2b94..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:34:51.956Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 48edb18..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From b78d3c188943be2d07227ed0ec32cc785edfe067 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 04:59:36 +0000 Subject: [PATCH 098/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f3a638b..48edb18 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 3ef80c17efba31219e479783b9f5d37737b8c44d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:00:07 +0000 Subject: [PATCH 099/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4afd3ed858ddad999f0e442d10036a1d5fe46c3a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:00:23 +0000 Subject: [PATCH 100/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 53 files changed, 4877 insertions(+), 7155 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 19b96ed..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:44:43.543Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 48edb18..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From c1c450f1bd87e5894cdb98a1f5058cf686680213 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 04:55:22 +0000 Subject: [PATCH 101/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f3a638b..48edb18 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 28495db938fb2fb0b6f2be4e41a5cb8595e46d30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:22:14 +0000 Subject: [PATCH 102/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e4337b4fe4cb1faaa825a0bb3bfac92e45624cce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:22:27 +0000 Subject: [PATCH 103/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 -- lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ----- test/test.object_mode.js | 279 -- test/test.validate.js | 241 - 53 files changed, 4877 insertions(+), 7155 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 a8bb738..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:47:58.385Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 48edb18..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From bc6e8c3012e207d40c298dd7c47106de3dea04eb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 05:11:22 +0000 Subject: [PATCH 104/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f1b0265..f25e483 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 8040555fe4cfc5bb4419e5dc556379f1a8ae1c94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:54:34 +0000 Subject: [PATCH 105/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;goxDA2BIA,wDAAQC,CAAQ,6BCLhBC,GAAWC,GAA6BD,SA+J5C,SAASE,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQC,GACvD,IAAIC,EACAC,EACAC,EACJ,KAAQC,gBAAgBT,IACvB,OAAKU,UAAUC,OAAS,EAChB,IAAIX,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQC,GAEpD,IAAIL,GAAoBC,EAAGC,EAAQC,EAAQC,GAEnD,IAAMQ,EAAsBX,GAC3B,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAEvC,IAAMS,EAAsBR,GAC3B,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAKH,EAAI,IACRO,EAAIJ,GAAWH,EAAE,GAAGE,EACfC,GAAUF,EAAOS,QAAUH,EAAI,GAAKA,GAAKN,EAAOS,QACpD,MAAM,IAAIM,WAAYH,EAAO,UAI/B,GADAR,EAAOY,EAAQ,GAAIC,IACdT,UAAUC,OAAS,IACvBJ,EC3JF,SAAmBD,EAAMD,GACxB,OAAMe,EAAUf,GAGXgB,EAAYhB,EAAS,SACzBC,EAAKgB,IAAMjB,EAAQiB,KACbC,EAAUjB,EAAKgB,MACb,IAAIT,UAAWC,EAAQ,QAAS,MAAOR,EAAKgB,MAGhDD,EAAYhB,EAAS,gBACzBC,EAAKkB,WAAanB,EAAQmB,YACpBC,EAAWnB,EAAKkB,aACd,IAAIX,UAAWC,EAAQ,QAAS,aAAcR,EAAKkB,aAGvDH,EAAYhB,EAAS,cACzBC,EAAKoB,SAAWrB,EAAQqB,UAClBH,EAAUjB,EAAKoB,WAAgC,OAAlBpB,EAAKoB,UAChC,IAAIb,UAAWC,EAAQ,QAAS,WAAYR,EAAKoB,WAGrDL,EAAYhB,EAAS,mBACzBC,EAAKqB,cAAgBtB,EAAQsB,eACvBC,EAAetB,EAAKqB,gBAClB,IAAId,UAAWC,EAAQ,QAAS,gBAAiBR,EAAKqB,gBAG1DN,EAAYhB,EAAS,eACzBC,EAAKuB,UAAYxB,EAAQwB,WACnBC,EAAYxB,EAAKuB,YACf,IAAIhB,UAAWC,EAAQ,QAAS,YAAaR,EAAKuB,YAGpD,KAhCC,IAAIhB,UAAWC,EAAQ,QAAST,GAiCzC,CDwHQ0B,CAAUzB,EAAMD,GACjBE,GACJ,MAAMA,EA+BR,OA3BAX,GAAO,wEAAyEoC,KAAKC,UAAW3B,IAChGR,GAASoC,KAAMzB,KAAMH,GAGrB6B,EAAkB1B,KAAM,cAAc,GAGtC2B,EAA0B3B,KAAM,cAAeH,EAAKkB,YAGpDY,EAA0B3B,KAAM,OAAQH,EAAKgB,KAG7Cc,EAA0B3B,KAAM,aAAcH,EAAKuB,WAAaG,KAAKC,WAGrEG,EAA0B3B,KAAM,UAAWP,GAG3CkC,EAA0B3B,KAAM,KAAMR,GACtCmC,EAA0B3B,KAAM,UAAWN,GAC3CiC,EAA0B3B,KAAM,UAAWL,GAC3C+B,EAAkB1B,KAAM,OAAQL,GAGhC+B,EAAkB1B,KAAM,KAAM,GAEvBA,IACR,CElLA,SAASe,GAAYvB,EAAGC,EAAQC,EAAQC,EAAQC,GAC/C,IAAIC,EACJ,GAAKI,UAAUC,OAAS,EAAI,CAE3B,IAAMS,EADNd,EAAOD,GAEN,MAAM,IAAIQ,UAAWC,EAAQ,QAASR,IAEvCA,EAAOY,EAAQ,GAAIb,EACrB,MACEC,EAAO,CAAA,EAGR,OADAA,EAAKkB,YAAa,EACX,IAAIxB,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQE,EAC3D,CCbA,SAAS+B,GAAShC,GACjB,IAAIC,EACJ,GAAKI,UAAUC,OAAS,CACvB,IAAMS,EAAUf,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvCC,EAAOY,EAAQ,GAAIb,EACrB,MACEC,EAAO,CAAA,EAER,OAeA,SAAuBL,EAAGC,EAAQC,EAAQC,GACzC,OAAO,IAAIJ,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQE,EAC1D,CACF,CH2JAgC,EAAStC,GAAoBF,IAY7BsC,EAA0BpC,GAAmBuC,UAAW,SApNxD,WAEC,IAAIC,EACAjC,EACAkC,EAEJ,IAAKhC,KAAKiC,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAjC,EAAM,KAENE,KAAKkC,IAAM,EACNlC,KAAKkC,GAAKlC,KAAKmC,GAEnB,OADAhD,GAAO,uBACAa,KAAKoC,KAAM,MAEnBJ,EAAIhC,KAAKqC,QAASrC,KAAKsC,MACvBnD,GAAO,gCAAiCoC,KAAKC,UAAWQ,GAAKhC,KAAKsC,KAAMtC,KAAKkC,IAE7ElC,KAAKsC,MAAQtC,KAAKuC,SACQ,IAArBvC,KAAKwC,cAES,iBADlBR,EAAIhC,KAAKyC,WAAYT,IAGnBA,EADgB,IAAZhC,KAAKkC,GACLQ,EAAeV,GAEfU,EAAe1C,KAAK2C,KAAKX,GAEnBY,EAAUZ,GAChBhC,KAAKkC,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1C,KAAK2C,MAAQX,KAGlDlC,EAAM,IAAIiD,MAAO1C,EAAQ,QAAS2B,KAG/BlC,EACJE,KAAKgD,KAAM,QAASlD,GAEpBiC,EAAM/B,KAAKoC,KAAMJ,EAElB,CAGF,IAiLAL,EAA0BpC,GAAmBuC,UAAW,WAxKxD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlD,KAAKiC,YACT9C,GAAO,qDACAa,OAERkD,EAAOlD,KACPA,KAAKiC,YAAa,EAElBkB,GASA,WACMF,IACJ9D,GAAO,mDAAsDiE,EAASH,GAAYA,EAAMI,QAAU9B,KAAKC,UAAWyB,IAClHC,EAAKF,KAAM,QAASC,IAErB9D,GAAO,yBACP+D,EAAKF,KAAM,QACX,IAdMhD,KAiBR,II/BAsD,EAAAC,GAAA,aAAAxC,IACAuC,EAAAC,GAAA,UAAA3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From da3a3e327af0b08de1425f76ebf6e9f95d7b7f3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:54:46 +0000 Subject: [PATCH 106/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 54 files changed, 4877 insertions(+), 7260 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 c5a6252..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T03:52:46.993Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;goxDA2BIA,wDAAQC,CAAQ,6BCLhBC,GAAWC,GAA6BD,SA+J5C,SAASE,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQC,GACvD,IAAIC,EACAC,EACAC,EACJ,KAAQC,gBAAgBT,IACvB,OAAKU,UAAUC,OAAS,EAChB,IAAIX,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQC,GAEpD,IAAIL,GAAoBC,EAAGC,EAAQC,EAAQC,GAEnD,IAAMQ,EAAsBX,GAC3B,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAEvC,IAAMc,EAAcb,GACnB,MAAM,IAAIW,UAAWC,EAAQ,QAASZ,IAEvC,IAAMc,EAAWb,GAChB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAEvC,IAAMS,EAAsBR,GAC3B,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAKH,EAAI,IACRO,EAAIJ,GAAWH,EAAE,GAAGE,EACfC,GAAUF,EAAOS,QAAUH,EAAI,GAAKA,GAAKN,EAAOS,QACpD,MAAM,IAAIM,WAAYH,EAAO,UAI/B,GADAR,EAAOY,EAAQ,GAAIC,IACdT,UAAUC,OAAS,IACvBJ,EC3JF,SAAmBD,EAAMD,GACxB,OAAMe,EAAUf,GAGXgB,EAAYhB,EAAS,SACzBC,EAAKgB,IAAMjB,EAAQiB,KACbC,EAAUjB,EAAKgB,MACb,IAAIT,UAAWC,EAAQ,QAAS,MAAOR,EAAKgB,MAGhDD,EAAYhB,EAAS,gBACzBC,EAAKkB,WAAanB,EAAQmB,YACpBC,EAAWnB,EAAKkB,aACd,IAAIX,UAAWC,EAAQ,QAAS,aAAcR,EAAKkB,aAGvDH,EAAYhB,EAAS,cACzBC,EAAKoB,SAAWrB,EAAQqB,UAClBH,EAAUjB,EAAKoB,WAAgC,OAAlBpB,EAAKoB,UAChC,IAAIb,UAAWC,EAAQ,QAAS,WAAYR,EAAKoB,WAGrDL,EAAYhB,EAAS,mBACzBC,EAAKqB,cAAgBtB,EAAQsB,eACvBC,EAAetB,EAAKqB,gBAClB,IAAId,UAAWC,EAAQ,QAAS,gBAAiBR,EAAKqB,gBAG1DN,EAAYhB,EAAS,eACzBC,EAAKuB,UAAYxB,EAAQwB,WACnBC,EAAYxB,EAAKuB,YACf,IAAIhB,UAAWC,EAAQ,QAAS,YAAaR,EAAKuB,YAGpD,KAhCC,IAAIhB,UAAWC,EAAQ,QAAST,GAiCzC,CDwHQ0B,CAAUzB,EAAMD,GACjBE,GACJ,MAAMA,EA+BR,OA3BAX,GAAO,wEAAyEoC,KAAKC,UAAW3B,IAChGR,GAASoC,KAAMzB,KAAMH,GAGrB6B,EAAkB1B,KAAM,cAAc,GAGtC2B,EAA0B3B,KAAM,cAAeH,EAAKkB,YAGpDY,EAA0B3B,KAAM,OAAQH,EAAKgB,KAG7Cc,EAA0B3B,KAAM,aAAcH,EAAKuB,WAAaG,KAAKC,WAGrEG,EAA0B3B,KAAM,UAAWP,GAG3CkC,EAA0B3B,KAAM,KAAMR,GACtCmC,EAA0B3B,KAAM,UAAWN,GAC3CiC,EAA0B3B,KAAM,UAAWL,GAC3C+B,EAAkB1B,KAAM,OAAQL,GAGhC+B,EAAkB1B,KAAM,KAAM,GAEvBA,IACR,CElLA,SAASe,GAAYvB,EAAGC,EAAQC,EAAQC,EAAQC,GAC/C,IAAIC,EACJ,GAAKI,UAAUC,OAAS,EAAI,CAE3B,IAAMS,EADNd,EAAOD,GAEN,MAAM,IAAIQ,UAAWC,EAAQ,QAASR,IAEvCA,EAAOY,EAAQ,GAAIb,EACrB,MACEC,EAAO,CAAA,EAGR,OADAA,EAAKkB,YAAa,EACX,IAAIxB,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQE,EAC3D,CCbA,SAAS+B,GAAShC,GACjB,IAAIC,EACJ,GAAKI,UAAUC,OAAS,CACvB,IAAMS,EAAUf,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvCC,EAAOY,EAAQ,GAAIb,EACrB,MACEC,EAAO,CAAA,EAER,OAeA,SAAuBL,EAAGC,EAAQC,EAAQC,GACzC,OAAO,IAAIJ,GAAoBC,EAAGC,EAAQC,EAAQC,EAAQE,EAC1D,CACF,CH2JAgC,EAAStC,GAAoBF,IAY7BsC,EAA0BpC,GAAmBuC,UAAW,SApNxD,WAEC,IAAIC,EACAjC,EACAkC,EAEJ,IAAKhC,KAAKiC,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAjC,EAAM,KAENE,KAAKkC,IAAM,EACNlC,KAAKkC,GAAKlC,KAAKmC,GAEnB,OADAhD,GAAO,uBACAa,KAAKoC,KAAM,MAEnBJ,EAAIhC,KAAKqC,QAASrC,KAAKsC,MACvBnD,GAAO,gCAAiCoC,KAAKC,UAAWQ,GAAKhC,KAAKsC,KAAMtC,KAAKkC,IAE7ElC,KAAKsC,MAAQtC,KAAKuC,SACQ,IAArBvC,KAAKwC,cAES,iBADlBR,EAAIhC,KAAKyC,WAAYT,IAGnBA,EADgB,IAAZhC,KAAKkC,GACLQ,EAAeV,GAEfU,EAAe1C,KAAK2C,KAAKX,GAEnBY,EAAUZ,GAChBhC,KAAKkC,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1C,KAAK2C,MAAQX,KAGlDlC,EAAM,IAAIiD,MAAO1C,EAAQ,QAAS2B,KAG/BlC,EACJE,KAAKgD,KAAM,QAASlD,GAEpBiC,EAAM/B,KAAKoC,KAAMJ,EAElB,CAGF,IAiLAL,EAA0BpC,GAAmBuC,UAAW,WAxKxD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlD,KAAKiC,YACT9C,GAAO,qDACAa,OAERkD,EAAOlD,KACPA,KAAKiC,YAAa,EAElBkB,GASA,WACMF,IACJ9D,GAAO,mDAAsDiE,EAASH,GAAYA,EAAMI,QAAU9B,KAAKC,UAAWyB,IAClHC,EAAKF,KAAM,QAASC,IAErB9D,GAAO,yBACP+D,EAAKF,KAAM,QACX,IAdMhD,KAiBR,II/BAsD,EAAAC,GAAA,aAAAxC,IACAuC,EAAAC,GAAA,UAAA3B"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index f25e483..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From 738ff06ea653b87e472a27feae6c18f2f88d6117 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 02:25:42 +0000 Subject: [PATCH 107/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f1b0265..f25e483 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 765bee4606186044c3960f2f71ae08e926304ec1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:07:25 +0000 Subject: [PATCH 108/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ef22ff649f3a78e293057a52624331bb6607e5c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:07:39 +0000 Subject: [PATCH 109/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 54 files changed, 4877 insertions(+), 7260 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 954fc9b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:12:27.373Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4ca79b..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af2495e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index f25e483..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -}); From d37d7e1fdf034ae36aba3e12d7499d8f6c02c04c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:45:21 +0000 Subject: [PATCH 110/112] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 14 +++++++------- lib/object_mode.js | 4 ++-- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b19b1f9..c948c8b 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -69,7 +69,7 @@ function factory( options ) { var opts; if ( arguments.length ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1MH2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 62e2ca5..404a38b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var nextTick = require( '@stdlib/utils-next-tick' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -83,7 +83,7 @@ function read() { v = Buffer.concat( [ string2buffer( this._sep ), v ] ); } } else { - err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) ); + err = new Error( format( '1MHA9', v ) ); } } if ( err ) { @@ -190,21 +190,21 @@ function StridedArrayStream( N, buffer, stride, offset, options ) { return new StridedArrayStream( N, buffer, stride, offset ); } if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); + throw new TypeError( format( '1MH2d', N ) ); } if ( !isCollection( buffer ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) ); + throw new TypeError( format( '1MH2y', buffer ) ); } if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); + throw new TypeError( format( '1MH2z', stride ) ); } if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); + throw new TypeError( format( '1MH30', offset ) ); } if ( N > 0 ) { i = offset + ((N-1)*stride); if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' ); + throw new RangeError( format('1MH1K') ); } } opts = assign( {}, DEFAULTS ); diff --git a/lib/object_mode.js b/lib/object_mode.js index c0c7043..08ffb8c 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var StridedArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( N, buffer, stride, offset, options ) { if ( arguments.length > 4 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MH2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 2f4fce4..72c2119 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1MH2V', options ) ); } if ( hasOwnProp( options, 'sep' ) ) { opts.sep = options.sep; if ( !isString( opts.sep ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) ); + return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); } } if ( hasOwnProp( options, 'objectMode' ) ) { opts.objectMode = options.objectMode; if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); + return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'encoding' ) ) { opts.encoding = options.encoding; if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) ); + return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); } } if ( hasOwnProp( options, 'highWaterMark' ) ) { opts.highWaterMark = options.highWaterMark; if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); + return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); } } if ( hasOwnProp( options, 'serialize' ) ) { opts.serialize = options.serialize; if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) ); + return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); } } return null; diff --git a/package.json b/package.json index f1b0265..f25e483 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/buffer-ctor": "^0.2.2", "@stdlib/buffer-from-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 8bb0c020f2da1727349eec0c7f0a980758b0b48d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:57:47 +0000 Subject: [PATCH 111/112] Remove files --- index.d.ts | 305 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5152 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 71fa81e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,305 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Readable } from 'stream'; -import { Collection } from '@stdlib/types/array'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies how `Buffer` objects should be decoded to strings (default: `null`). - */ - encoding?: string | null; - - /** - * Specifies the maximum number of bytes to store in an internal buffer before pausing streaming. - */ - highWaterMark?: number; - - /** - * Separator used to join streamed data (default: `'\n'`). - */ - sep?: string; - - /** - * Custom serialization function. - */ - serialize?: Function; -} - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var StridedArrayStream = stridedArrayStream; - * var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to strings (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws linear index cannot exceed array bounds - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( chunk ) { - * console.log( chunk.toString() ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from strided array-like values. - * - * @param options - stream options - * @param options.objectMode - specifies whether a stream should operate in object mode (default: false) - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of bytes to store in an internal buffer before pausing streaming - * @param options.sep - separator used to join streamed data (default: '\n') - * @param options.serialize - custom serialization function - * @returns stream factory - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var opts = { - * 'sep': ',', - * 'objectMode': false, - * 'encoding': 'utf8', - * 'highWaterMark': 64 - * }; - * - * var createStream = stridedArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr.length, arr, 1, 0 ) ); - * } - */ - factory( options?: Options ): ( N: number, buffer: Collection, stride: number, offset: number ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like value. - * - * @param N - number of values to stream - * @param buffer - source value - * @param stride - stride length - * @param offset - starting index - * @param options - stream options - * @param options.encoding - specifies how `Buffer` objects should be decoded to `strings` (default: null) - * @param options.highWaterMark - specifies the maximum number of objects to store in an internal buffer before pausing streaming - * @throws first argument must be a nonnegative integer - * @throws second argument must be an array-like object - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @throws options argument must be an object - * @throws must provide valid options - * @returns stream instance - * - * @example - * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); - * var Float64Array = require( '@stdlib/array-float64' ); - * var randu = require( '@stdlib/random-base-randu' ); - * - * function log( v ) { - * console.log( v ); - * } - * - * var arr = new Float64Array( 10 ); - * var i; - * for ( i = 0; i < arr.length; i++ ) { - * arr[ i ] = randu(); - * } - * - * var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( N: number, buffer: Collection, stride: number, offset: number, options?: Options ): Readable; -} - -/** -* Creates a readable stream from a strided array-like object. -* -* @param N - number of values to stream -* @param buffer - source value -* @param stride - stride length -* @param offset - starting index -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var StridedArrayStream = stridedArrayStream; -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var stridedArrayStream: Constructor; - - -// EXPORTS // - -export = stridedArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af2495e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b091e8a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 255963a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aee88a40dff258f822231870426ccd2758d02c35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:58:05 +0000 Subject: [PATCH 112/112] 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 | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 269 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 155 - docs/types/test.ts | 189 - examples/index.js | 51 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 5 - lib/factory.js | 101 - lib/index.js | 110 - lib/main.js | 279 - lib/object_mode.js | 86 - lib/validate.js | 97 - package.json | 77 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 376 -- test/test.js | 43 - test/test.main.js | 1139 ---- test/test.object_mode.js | 279 - test/test.validate.js | 241 - 54 files changed, 4877 insertions(+), 7263 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.throughput.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 (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/debug.js delete mode 100644 lib/defaults.json delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.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 95c7480..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T00:42:43.080Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index cf2b727..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a456072..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/streams/node/from-strided-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9e0a00c..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: '41 5 * * 5' - - # 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 + + ```
@@ -275,7 +272,7 @@ stream.pipe( iStream ); ## 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]. @@ -346,7 +343,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array +[@stdlib/streams/node/from-array]: https://github.com/stdlib-js/streams-node-from-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 178e5cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':objectMode', function benchmark( b ) { - var arr; - var s; - var i; - - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::factory', function benchmark( b ) { - var createStream; - var arr; - var s; - var i; - - createStream = stridedArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr.length, arr, 1, 0 ); - if ( typeof s !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( s instanceof Readable ) ) { - b.fail( 'should return a readable stream' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8b0863f..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,269 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var stridedArrayStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = {}; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = {}; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); - -bench( pkg+'::throughput,object_mode:highWaterMark=0', function benchmark( b ) { - var rStream; - var wStream; - var opts; - var arr; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = next; // eslint-disable-line no-underscore-dangle - - arr = []; - for ( i = 0; i < b.iterations; i++ ) { - arr.push( i ); - } - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = stridedArrayStream.objectMode( arr.length, arr, 1, 0, opts ); - - // Create a sink stream: - opts = { - 'objectMode': true - }; - wStream = new Writable( opts ); - - i = 0; - b.tic(); - - return pipe(); - - function pipe() { - // Begin data flow... - rStream.pipe( wStream ); - } - - function next( chunk, encoding, clbk ) { - i += 1; - if ( i < b.iterations ) { - return clbk(); - } - b.toc(); - rStream.destroy(); - - b.pass( 'benchmark finished' ); - b.end(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f2c21d5..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/streams/node/from-strided-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-strided-array -[production-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-strided-array/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 1662a75..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import stridedArrayStream from '../docs/types/index'; -export = stridedArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09a36fa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=o(function(ve,F){F.exports={objectMode:!1,encoding:null,sep:"\n"}});var _=o(function(ge,w){"use strict";var N=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),P=require("@stdlib/assert-is-boolean").isPrimitive,W=require("@stdlib/assert-is-nonnegative-number").isPrimitive,p=require("@stdlib/assert-is-string").isPrimitive,A=require("@stdlib/assert-is-function"),d=require("@stdlib/string-format");function R(e,r){return N(r)?v(r,"sep")&&(e.sep=r.sep,!p(e.sep))?new TypeError(d("invalid option. `%s` option must be a string. Option: `%s`.","sep",e.sep)):v(r,"objectMode")&&(e.objectMode=r.objectMode,!P(e.objectMode))?new TypeError(d("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):v(r,"encoding")&&(e.encoding=r.encoding,!p(e.encoding)&&e.encoding!==null)?new TypeError(d("invalid option. `%s` option must be a string or null. Option: `%s`.","encoding",e.encoding)):v(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!W(e.highWaterMark))?new TypeError(d("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):v(r,"serialize")&&(e.serialize=r.serialize,!A(e.serialize))?new TypeError(d("invalid option. `%s` option must be a function. Option: `%s`.","serialize",e.serialize)):null:new TypeError(d("invalid argument. Options argument must be an object. Value: `%s`.",r))}w.exports=R});var M=o(function(ce,j){"use strict";var B=require("debug"),I=B("from-strided-array-stream");j.exports=I});var c=o(function(me,S){"use strict";var O=require("readable-stream").Readable,J=require("@stdlib/assert-is-collection"),C=require("@stdlib/assert-is-error"),L=require("@stdlib/assert-is-buffer"),D=require("@stdlib/assert-is-integer").isPrimitive,E=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,G=require("@stdlib/object-assign"),U=require("@stdlib/utils-inherit"),f=require("@stdlib/utils-define-nonenumerable-property"),n=require("@stdlib/utils-define-nonenumerable-read-only-property"),b=require("@stdlib/buffer-from-string"),H=require("@stdlib/buffer-ctor"),g=require("@stdlib/string-format"),K=require("@stdlib/utils-next-tick"),Q=q(),X=_(),l=M();function Y(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._N)return l("Finished iteration."),this.push(null);i=this._buffer[this._idx],l("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=b(i):i=b(this._sep+i):L(i)?this._i>1&&(i=H.concat([b(this._sep),i])):r=new Error(g("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",i))),r?this.emit("error",r):e=this.push(i)}}function Z(e){var r;if(this._destroyed)return l("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,K(i),this;function i(){e&&(l("Stream was destroyed due to an error. Error: %s.",C(e)?e.message:JSON.stringify(e)),r.emit("error",e)),l("Closing the stream..."),r.emit("close")}}function u(e,r,i,a,s){var t,h,m;if(!(this instanceof u))return arguments.length>4?new u(e,r,i,a,s):new u(e,r,i,a);if(!E(e))throw new TypeError(g("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",e));if(!J(r))throw new TypeError(g("invalid argument. Second argument must be an array-like object. Value: `%s`.",r));if(!D(i))throw new TypeError(g("invalid argument. Third argument must be an integer. Value: `%s`.",i));if(!E(a))throw new TypeError(g("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",a));if(e>0&&(m=a+(e-1)*i,a>=r.length||m<0||m>=r.length))throw new RangeError("invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.");if(t=G({},Q),arguments.length>4&&(h=X(t,s),h))throw h;return l("Creating a readable stream configured with the following options: %s.",JSON.stringify(t)),O.call(this,t),f(this,"_destroyed",!1),n(this,"_objectMode",t.objectMode),n(this,"_sep",t.sep),n(this,"_serialize",t.serialize||JSON.stringify),n(this,"_buffer",r),n(this,"_N",e),n(this,"_stride",i),n(this,"_offset",a),f(this,"_idx",a),f(this,"_i",0),this}U(u,O);n(u.prototype,"_read",Y);n(u.prototype,"destroy",Z);S.exports=u});var x=o(function(fe,T){"use strict";var $=require("@stdlib/assert-is-plain-object"),ee=require("@stdlib/string-format"),re=require("@stdlib/object-assign"),ie=c();function te(e,r,i,a,s){var t;if(arguments.length>4){if(t=s,!$(t))throw new TypeError(ee("invalid argument. Options argument must be an object. Value: `%s`.",t));t=re({},s)}else t={};return t.objectMode=!0,new ie(e,r,i,a,t)}T.exports=te});var k=o(function(be,z){"use strict";var ae=require("@stdlib/assert-is-plain-object"),ne=require("@stdlib/string-format"),se=require("@stdlib/object-assign"),ue=c();function oe(e){var r;if(arguments.length){if(!ae(e))throw new TypeError(ne("invalid argument. Options argument must be an object. Value: `%s`.",e));r=se({},e)}else r={};return i;function i(a,s,t,h){return new ue(a,s,t,h,r)}}z.exports=oe});var V=require("@stdlib/utils-define-nonenumerable-read-only-property"),y=c(),de=x(),le=k();V(y,"objectMode",de);V(y,"factory",le);module.exports=y; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 8386ee7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar format = require( '@stdlib/string-format' );\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Strided array parameters are incompatible with the provided array-like object. Linear index exceeds array bounds.' );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = StridedArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar StridedArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "isInteger", "isNonNegativeInteger", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "format", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "StridedArrayStream", "N", "buffer", "stride", "offset", "options", "opts", "i", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "objectMode", "N", "buffer", "stride", "offset", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "StridedArrayStream", "factory", "options", "opts", "createStream", "N", "buffer", "stride", "offset", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index acf0905..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,155 +0,0 @@ - -{{alias}}( N, buffer, stride, offset[, options] ) - Creates a readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - In binary mode, if an array contains `undefined` values, the stream will - emit an error. Consider providing a custom serialization function or - filtering `undefined` values prior to invocation. - - If a serialization function fails to return a string or Buffer, the stream - emits an error. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing the stream. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); - > s.pipe( o ); - - -{{alias}}.factory( [options] ) - Returns a function for creating readable streams from array-like objects. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before pausing streaming. - - options.sep: string (optional) - Separator used to join streamed data. This option is only applicable - when a stream is not in "objectMode". Default: '\n'. - - options.serialize: Function (optional) - Serialization function. The default behavior is to serialize streamed - values as JSON strings. This option is only applicable when a stream is - not in "objectMode". - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( N, buffer, stride, offset[, options] ) - Returns an "objectMode" readable stream from a strided array-like object. - - In object mode, `null` is a reserved value. If an array contains `null` - values (e.g., as a means to encode missing values), the stream will - prematurely end. Consider an alternative encoding or filter `null` values - prior to invocation. - - Parameters - ---------- - N: integer - Number of values to stream. - - buffer: ArrayLikeObject - Array-like object from which to create the stream. - - stride: integer - Stride length. - - offset: integer - Starting index. - - options: Object (optional) - Options. - - options.encoding: string|null (optional) - Specifies how Buffer objects should be decoded to strings. Default: - null. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before pausing streaming. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); - > s.pipe( o ); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 39d97b7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 StridedArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - new StridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const arr = [ 1, 2, 3, 4 ]; - const stridedArrayStream = StridedArrayStream; - stridedArrayStream( arr.length, arr, 1, 0 ); // $ExpectType Readable - stridedArrayStream( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0 ); // $ExpectType Readable - StridedArrayStream.objectMode( arr.length, arr, 1, 0, { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const arr = [ 1, 2, 3, 4 ]; - const f = StridedArrayStream.factory(); - f( arr.length, arr, 1, 0 ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( 'abc', arr, 1, 0 ); // $ExpectError - new StridedArrayStream( true, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( false, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( [], arr, 1, 0 ); // $ExpectError - new StridedArrayStream( {}, arr, 1, 0 ); // $ExpectError - new StridedArrayStream( null, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, 123, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, true, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, false, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, {}, 1, 0 ); // $ExpectError - new StridedArrayStream( arr.length, null, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 'abc', 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, true, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, false, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, [], 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, {}, 0 ); // $ExpectError - new StridedArrayStream( arr.length, arr, null, 0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, {} ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, null ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - new StridedArrayStream( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, 123 ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, true ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, false ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, [] ); // $ExpectError - new StridedArrayStream( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( 'abc', arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( null, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( true, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( false, arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( [], arr, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( {}, arr, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not a collection... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, null, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, 123, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, true, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, false, 1, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a third argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 'abc', 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, null, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, true, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, false, 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, [], 0 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fourth argument which is not a number... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, null ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, {} ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a fifth argument which is not an options object... -{ - const arr = [ 1, 2, 3, 4 ]; - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 'abc' ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, 123 ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, true ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, false ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, [] ); // $ExpectError - StridedArrayStream.objectMode( arr.length, arr, 1, 0, null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - StridedArrayStream.factory( 'abc' ); // $ExpectError - StridedArrayStream.factory( 123 ); // $ExpectError - StridedArrayStream.factory( true ); // $ExpectError - StridedArrayStream.factory( false ); // $ExpectError - StridedArrayStream.factory( [] ); // $ExpectError - StridedArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - const arr = [ 1, 2, 3, 4 ]; - let f = StridedArrayStream.factory(); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError - - f = StridedArrayStream.factory( { 'objectMode': true } ); - f(); // $ExpectError - f( arr.length ); // $ExpectError - f( arr.length, arr ); // $ExpectError - f( arr.length, arr, 1 ); // $ExpectError - f( arr.length, arr, 1, 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc144f2..0000000 --- a/examples/index.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'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var stridedArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 20 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Create a stream which iterates over every other element from right-to-left: -var opts = { - 'objectMode': true -}; -var stream = stridedArrayStream( 10, arr, -2, arr.length-2, opts ); - -// Create a writable stream for inspecting stream data: -opts = { - 'objectMode': true -}; -var iStream = inspectStream( opts, log ); - -// Begin data flow: -stream.pipe( iStream ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index f9f354c..71fa81e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /// -/// +/// import { Readable } from 'stream'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9487404 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}function b(){}function _(){_.init.call(this)}function E(e){return void 0===e._maxListeners?_.defaultMaxListeners:e._maxListeners}function R(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new b,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=E(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function j(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function S(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),_.EventEmitter=_,_.usingDomains=!1,_.prototype.domain=void 0,_.prototype._events=void 0,_.prototype._maxListeners=void 0,_.defaultMaxListeners=10,_.init=function(){this.domain=null,_.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(e){var t,r,n,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new b,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T=[],L=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function P(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)T[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function C(e,t,r){for(var n,i,o=[],s=t;s>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return o.join("")}function O(e){var t;x||P();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=T[t>>2],i+=T[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=T[t>>10],i+=T[t>>4&63],i+=T[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function U(e,t,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,h-=8);e[r+d-p]|=128*g}var D={}.toString,I=Array.isArray||function(e){return"[object Array]"==D.call(e)};function z(){return N.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Y(e,t){if(z()=z())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z().toString(16)+" bytes");return 0|e}function V(e){return!(null==e||!e._isBuffer)}function $(e,t){if(V(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return _e(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ee(e).length;default:if(n)return _e(e).length;t=(""+t).toLowerCase(),n=!0}}function G(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return fe(this,t,r);case"utf8":case"utf-8":return se(this,t,r);case"ascii":return ue(this,t,r);case"latin1":case"binary":return he(this,t,r);case"base64":return oe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Z(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function K(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=N.from(t,n)),V(t))return 0===t.length?-1:Q(e,t,r,n,i);if("number"==typeof t)return t&=255,N.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Q(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Q(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function oe(e,t,r){return 0===t&&r===e.length?O(e):O(e.slice(t,r))}function se(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(f=h);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&h)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=ae)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},N.prototype.compare=function(e,t,r,n,i){if(!V(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return X(this,e,t,r);case"utf8":case"utf-8":return ee(this,e,t,r);case"ascii":return te(this,e,t,r);case"latin1":case"binary":return re(this,e,t,r);case"base64":return ne(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ae=4096;function ue(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function de(e,t,r,n,i,o){if(!V(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function pe(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ge(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ve(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ye(e,t,r,n,i){return i||ve(e,0,r,4),U(e,t,r,n,23,4),r+4}function we(e,t,r,n,i){return i||ve(e,0,r,8),U(e,t,r,n,52,8),r+8}N.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},N.prototype.readUInt8=function(e,t){return t||ce(e,1,this.length),this[e]},N.prototype.readUInt16LE=function(e,t){return t||ce(e,2,this.length),this[e]|this[e+1]<<8},N.prototype.readUInt16BE=function(e,t){return t||ce(e,2,this.length),this[e]<<8|this[e+1]},N.prototype.readUInt32LE=function(e,t){return t||ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},N.prototype.readUInt32BE=function(e,t){return t||ce(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},N.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},N.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ce(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},N.prototype.readInt8=function(e,t){return t||ce(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},N.prototype.readInt16LE=function(e,t){t||ce(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt16BE=function(e,t){t||ce(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},N.prototype.readInt32LE=function(e,t){return t||ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},N.prototype.readInt32BE=function(e,t){return t||ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},N.prototype.readFloatLE=function(e,t){return t||ce(e,4,this.length),B(this,e,!0,23,4)},N.prototype.readFloatBE=function(e,t){return t||ce(e,4,this.length),B(this,e,!1,23,4)},N.prototype.readDoubleLE=function(e,t){return t||ce(e,8,this.length),B(this,e,!0,52,8)},N.prototype.readDoubleBE=function(e,t){return t||ce(e,8,this.length),B(this,e,!1,52,8)},N.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||de(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},N.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,255,0),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},N.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,65535,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ge(this,e,t,!0),t+4},N.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,4294967295,0),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},N.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);de(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},N.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,1,127,-128),N.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},N.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):pe(this,e,t,!0),t+2},N.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,2,32767,-32768),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):pe(this,e,t,!1),t+2},N.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),N.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ge(this,e,t,!0),t+4},N.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||de(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),N.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ge(this,e,t,!1),t+4},N.prototype.writeFloatLE=function(e,t,r){return ye(this,e,t,!0,r)},N.prototype.writeFloatBE=function(e,t,r){return ye(this,e,t,!1,r)},N.prototype.writeDoubleLE=function(e,t,r){return we(this,e,t,!0,r)},N.prototype.writeDoubleBE=function(e,t,r){return we(this,e,t,!1,r)},N.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!N.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ee(e){return function(e){var t,r,n,i,o,s;x||P();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new k(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=L[e.charCodeAt(t)]<<2|L[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=L[e.charCodeAt(t)]<<10|L[e.charCodeAt(t+1)]<<4|L[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(me,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Re(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Se(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var Ae=Se,Te=Me;function Le(e){if(Ae===setTimeout)return setTimeout(e,0);if((Ae===Se||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(e,0);try{return Ae(e,0)}catch(t){try{return Ae.call(null,e,0)}catch(t){return Ae.call(this,e,0)}}}"function"==typeof A.setTimeout&&(Ae=setTimeout),"function"==typeof A.clearTimeout&&(Te=clearTimeout);var ke,xe=[],Pe=!1,Ce=-1;function Oe(){Pe&&ke&&(Pe=!1,ke.length?xe=ke.concat(xe):Ce=-1,xe.length&&Be())}function Be(){if(!Pe){var e=Le(Oe);Pe=!0;for(var t=xe.length;t;){for(ke=xe,xe=[];++Ce1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!dt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),lt(r.showHidden)&&(r.showHidden=!1),lt(r.depth)&&(r.depth=2),lt(r.colors)&&(r.colors=!1),lt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=nt),ot(r,e,r.depth)}function nt(e,t){var r=rt.styles[t];return r?"["+rt.colors[r][0]+"m"+e+"["+rt.colors[r][1]+"m":e}function it(e,t){return e}function ot(e,t,r){if(e.customInspect&&t&&vt(t.inspect)&&t.inspect!==rt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ft(n)||(n=ot(e,n,r)),n}var i=function(e,t){if(lt(t))return e.stylize("undefined","undefined");if(ft(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(ut(t))return e.stylize(""+t,"boolean");if(ht(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),gt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return st(t);if(0===o.length){if(vt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ct(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(pt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(gt(t))return st(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),vt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return ct(t)&&(f=" "+RegExp.prototype.toString.call(t)),pt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),gt(t)&&(f=" "+st(t)),0!==o.length||l&&0!=t.length?r<0?ct(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),h=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(h,f,c)):c[0]+f+c[1]}function st(e){return"["+Error.prototype.toString.call(e)+"]"}function at(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),wt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ht(r)?ot(e,u.value,null):ot(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),lt(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function ut(e){return"boolean"==typeof e}function ht(e){return null===e}function ft(e){return"string"==typeof e}function lt(e){return void 0===e}function ct(e){return dt(e)&&"[object RegExp]"===yt(e)}function dt(e){return"object"==typeof e&&null!==e}function pt(e){return dt(e)&&"[object Date]"===yt(e)}function gt(e){return dt(e)&&("[object Error]"===yt(e)||e instanceof Error)}function vt(e){return"function"==typeof e}function yt(e){return Object.prototype.toString.call(e)}function wt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mt(){this.head=null,this.tail=null,this.length=0}rt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},rt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},mt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},mt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},mt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},mt.prototype.clear=function(){this.head=this.tail=null,this.length=0},mt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},mt.prototype.concat=function(e){if(0===this.length)return N.alloc(0);if(1===this.length)return this.head.data;for(var t=N.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var bt=N.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!bt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Rt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=jt;break;default:return void(this.write=Et)}this.charBuffer=new N(6),this.charReceived=0,this.charLength=0}function Et(e){return e.toString(this.encoding)}function Rt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function jt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},At.ReadableState=Mt;var St=function(e){if(lt(et)&&(et=Ge.env.NODE_DEBUG||""),e=e.toUpperCase(),!tt[e])if(new RegExp("\\b"+e+"\\b","i").test(et)){tt[e]=function(){var t=Qe.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else tt[e]=function(){};return tt[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof tr&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function At(e){if(!(this instanceof At))return new At(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_.call(this)}function Tt(e,t,r,n,i){var o=function(e,t){var r=null;N.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,xt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&xt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ue(Ct,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Lt?e=Lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function xt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(St("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ue(Pt,e):Pt(e))}function Pt(e){St("emit readable"),e.emit("readable"),Ut(e)}function Ct(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=N.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function It(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ue(zt,t,e))}function zt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Yt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return St("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?It(this):xt(this),null;if(0===(e=kt(e,t))&&t.ended)return 0===t.length&&It(this),null;var n,i=t.needReadable;return St("need readable",i),(0===t.length||t.length-e0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&It(this)),null!==n&&this.emit("data",n),n},At.prototype._read=function(e){this.emit("error",new Error("not implemented"))},At.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,St("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){St("onunpipe"),e===r&&h()}function s(){St("onend"),e.end()}n.endEmitted?Ue(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;St("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ut(e))}}(r);e.on("drain",a);var u=!1;function h(){St("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",h),r.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var f=!1;function l(t){St("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Yt(n.pipes,e))&&!u&&(St("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;St("onerror",t),g(),e.removeListener("error",c),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){St("onfinish"),e.removeListener("close",d),g()}function g(){St("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",c),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(St("pipe resume"),r.resume()),e},At.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ht.prototype._write=function(e,t,r){r(new Error("not implemented"))},Ht.prototype._writev=null,Ht.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Zt(e,t),r&&(t.finished?Ue(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(tr,At);for(var Qt=Object.keys(Ht.prototype),Xt=0;Xt()=>{}}))("from-strided-array-stream"),cr=hr.Readable;function dr(r,n,a,h,f){var c,m,b;if(!(this instanceof dr))return arguments.length>4?new dr(r,n,a,h,f):new dr(r,n,a,h);if(!o(r))throw new TypeError(l("1MH2d",r));if(!t(n))throw new TypeError(l("1MH2y",n));if(!i(a))throw new TypeError(l("1MH2z",a));if(!o(h))throw new TypeError(l("1MH30",h));if(r>0&&(b=h+(r-1)*a,h>=n.length||b<0||b>=n.length))throw new RangeError(l("1MH1K"));if(c=s({},fr),arguments.length>4&&(m=function(e,t){return d(t)?p(t,"sep")&&(e.sep=t.sep,!y(e.sep))?new TypeError(l("1MH2W","sep",e.sep)):p(t,"objectMode")&&(e.objectMode=t.objectMode,!g(e.objectMode))?new TypeError(l("1MH2o","objectMode",e.objectMode)):p(t,"encoding")&&(e.encoding=t.encoding,!y(e.encoding)&&null!==e.encoding)?new TypeError(l("1MH7n","encoding",e.encoding)):p(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!v(e.highWaterMark))?new TypeError(l("1MH4k","highWaterMark",e.highWaterMark)):p(t,"serialize")&&(e.serialize=t.serialize,!w(e.serialize))?new TypeError(l("1MH6p","serialize",e.serialize)):null:new TypeError(l("1MH2V",t))}(c,f),m))throw m;return lr("Creating a readable stream configured with the following options: %s.",JSON.stringify(c)),cr.call(this,c),u(this,"_destroyed",!1),e(this,"_objectMode",c.objectMode),e(this,"_sep",c.sep),e(this,"_serialize",c.serialize||JSON.stringify),e(this,"_buffer",n),e(this,"_N",r),e(this,"_stride",a),e(this,"_offset",h),u(this,"_idx",h),u(this,"_i",0),this}function pr(e,t,r,n,i){var o;if(arguments.length>4){if(!d(o=i))throw new TypeError(l("1MH2V",o));o=s({},i)}else o={};return o.objectMode=!0,new dr(e,t,r,n,o)}function gr(e){var t;if(arguments.length){if(!d(e))throw new TypeError(l("1MH2V",e));t=s({},e)}else t={};return function(e,r,n,i){return new dr(e,r,n,i,t)}}a(dr,cr),e(dr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._N)return lr("Finished iteration."),this.push(null);r=this._buffer[this._idx],lr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),this._idx+=this._stride,!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?h(r):h(this._sep+r):n(r)?this._i>1&&(r=f.concat([h(this._sep),r])):t=new Error(l("1MHA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(dr.prototype,"destroy",(function(e){var t;return this._destroyed?(lr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,c((function(){e&&(lr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));lr("Closing the stream..."),t.emit("close")})),this)})),e(dr,"objectMode",pr),e(dr,"factory",gr);export{dr as default,gr as factory,pr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b091e8a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/main.js","../lib/validate.js","../lib/object_mode.js","../lib/factory.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// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-strided-array-stream' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nimport isCollection from '@stdlib/assert-is-collection';\nimport isError from '@stdlib/assert-is-error';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport setNonEnumerable from '@stdlib/utils-define-nonenumerable-property';\nimport setNonEnumerableReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport string2buffer from '@stdlib/buffer-from-string';\nimport Buffer from '@stdlib/buffer-ctor'; // TODO: replace Buffer.concat usage with stdlib pkg\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport nextTick from '@stdlib/utils-next-tick';\nimport DEFAULTS from './defaults.json';\nimport validate from './validate.js';\nimport debug from './debug.js';\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._N ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._buffer[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( '1MHA9', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {RangeError} linear index cannot exceed array bounds\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new StridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction StridedArrayStream( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tvar err;\n\tvar i;\n\tif ( !( this instanceof StridedArrayStream ) ) {\n\t\tif ( arguments.length > 4 ) {\n\t\t\treturn new StridedArrayStream( N, buffer, stride, offset, options );\n\t\t}\n\t\treturn new StridedArrayStream( N, buffer, stride, offset );\n\t}\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( '1MH2d', N ) );\n\t}\n\tif ( !isCollection( buffer ) ) {\n\t\tthrow new TypeError( format( '1MH2y', buffer ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( '1MH2z', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( '1MH30', offset ) );\n\t}\n\tif ( N > 0 ) {\n\t\ti = offset + ((N-1)*stride);\n\t\tif ( offset >= buffer.length || i < 0 || i >= buffer.length ) {\n\t\t\tthrow new RangeError( format('1MH1K') );\n\t\t}\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 4 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_buffer', buffer );\n\n\t// Cache the strided array parameters:\n\tsetNonEnumerableReadOnly( this, '_N', N );\n\tsetNonEnumerableReadOnly( this, '_stride', stride );\n\tsetNonEnumerableReadOnly( this, '_offset', offset );\n\tsetNonEnumerable( this, '_idx', offset );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( StridedArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof StridedArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {StridedArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default StridedArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isFunction from '@stdlib/assert-is-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1MH2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( '1MH2W', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( '1MH7n', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( '1MH6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like value.\n*\n* @param {NonNegativeInteger} N - number of values to stream\n* @param {Collection} buffer - source value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {StridedArrayStream} Stream instance\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( N, buffer, stride, offset, options ) {\n\tvar opts;\n\tif ( arguments.length > 4 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport StridedArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from strided array-like values.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MH2V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} N - number of values to stream\n\t* @param {Collection} buffer - source array-like object\n\t* @param {integer} stride - stride length\n\t* @param {NonNegativeInteger} offset - starting index\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {StridedArrayStream} Stream instance\n\t*/\n\tfunction createStream( N, buffer, stride, offset ) {\n\t\treturn new StridedArrayStream( N, buffer, stride, offset, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from a strided array-like value.\n*\n* @module @stdlib/streams-node-from-strided-array\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = stridedArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr.length, arr, 1, 0 ) );\n* }\n*\n* @example\n* import inspectStream from '@stdlib/streams-node-inspect-sink';\n* import Float64Array from '@stdlib/array-float64';\n* import randu from '@stdlib/random-base-randu';\n* import stridedArrayStream from '@stdlib/streams-node-from-strided-array';\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["debug","logger","Readable","require$$0","StridedArrayStream","N","buffer","stride","offset","options","opts","err","i","this","arguments","length","isNonNegativeInteger","TypeError","format","isCollection","isInteger","RangeError","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_N","push","_buffer","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index 78729ac..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); - - -// MAIN // - -var debug = logger( 'from-strided-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 870b0e1..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index c948c8b..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from strided array-like values. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} options argument must be an object -* @returns {Function} stream factory -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MH2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from an array-like object. - * - * @private - * @param {NonNegativeInteger} N - number of values to stream - * @param {Collection} buffer - source array-like object - * @param {integer} stride - stride length - * @param {NonNegativeInteger} offset - starting index - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {StridedArrayStream} Stream instance - */ - function createStream( N, buffer, stride, offset ) { - return new StridedArrayStream( N, buffer, stride, offset, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 825a6c8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a readable stream from a strided array-like value. -* -* @module @stdlib/streams-node-from-strided-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var opts = { -* 'sep': ',', -* 'objectMode': false, -* 'encoding': 'utf8', -* 'highWaterMark': 64 -* }; -* -* var createStream = stridedArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr.length, arr, 1, 0 ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var stridedArrayStream = require( '@stdlib/streams-node-from-strided-array' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = stridedArrayStream.objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 404a38b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Readable = require( 'readable-stream' ).Readable; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isError = require( '@stdlib/assert-is-error' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var DEFAULTS = require( './defaults.json' ); -var validate = require( './validate.js' ); -var debug = require( './debug.js' ); - - -// FUNCTIONS // - -/** -* Implements the `_read` method. -* -* @private -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -function read() { - /* eslint-disable no-invalid-this */ - var FLG; - var err; - var v; - - if ( this._destroyed ) { - return; - } - FLG = true; - while ( FLG ) { - err = null; - - this._i += 1; - if ( this._i > this._N ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - v = this._buffer[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - this._idx += this._stride; - if ( this._objectMode === false ) { - v = this._serialize( v ); - if ( typeof v === 'string' ) { - if ( this._i === 1 ) { - v = string2buffer( v ); - } else { - v = string2buffer( this._sep+v ); - } - } else if ( isBuffer( v ) ) { - if ( this._i > 1 ) { - v = Buffer.concat( [ string2buffer( this._sep ), v ] ); - } - } else { - err = new Error( format( '1MHA9', v ) ); - } - } - if ( err ) { - this.emit( 'error', err ); - } else { - FLG = this.push( v ); - } - } - - /* eslint-enable no-invalid-this */ -} - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @private -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -function destroy( error ) { - /* eslint-disable no-invalid-this */ - var self; - if ( this._destroyed ) { - debug( 'Attempted to destroy an already destroyed stream.' ); - return this; - } - self = this; - this._destroyed = true; - - nextTick( close ); - - return this; - - /** - * Closes a stream. - * - * @private - */ - function close() { - if ( error ) { - debug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) ); - self.emit( 'error', error ); - } - debug( 'Closing the stream...' ); - self.emit( 'close' ); - } - - /* eslint-enable no-invalid-this */ -} - - -// MAIN // - -/** -* Stream constructor for generating a readable stream from an array-like object. -* -* @constructor -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming -* @param {string} [options.sep='\n'] - separator used to join streamed data -* @param {Function} [options.serialize] - custom serialization function -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {RangeError} linear index cannot exceed array bounds -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( chunk ) { -* console.log( chunk.toString() ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = new StridedArrayStream( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function StridedArrayStream( N, buffer, stride, offset, options ) { - var opts; - var err; - var i; - if ( !( this instanceof StridedArrayStream ) ) { - if ( arguments.length > 4 ) { - return new StridedArrayStream( N, buffer, stride, offset, options ); - } - return new StridedArrayStream( N, buffer, stride, offset ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( '1MH2d', N ) ); - } - if ( !isCollection( buffer ) ) { - throw new TypeError( format( '1MH2y', buffer ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( '1MH2z', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( '1MH30', offset ) ); - } - if ( N > 0 ) { - i = offset + ((N-1)*stride); - if ( offset >= buffer.length || i < 0 || i >= buffer.length ) { - throw new RangeError( format('1MH1K') ); - } - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 4 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - // Make the stream a readable stream: - debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) ); - Readable.call( this, opts ); - - // Destruction state: - setNonEnumerable( this, '_destroyed', false ); - - // Cache whether the stream is operating in object mode: - setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode ); - - // Cache the separator: - setNonEnumerableReadOnly( this, '_sep', opts.sep ); - - // Define the serialization function: - setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify ); - - // Cache the data source: - setNonEnumerableReadOnly( this, '_buffer', buffer ); - - // Cache the strided array parameters: - setNonEnumerableReadOnly( this, '_N', N ); - setNonEnumerableReadOnly( this, '_stride', stride ); - setNonEnumerableReadOnly( this, '_offset', offset ); - setNonEnumerable( this, '_idx', offset ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( StridedArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof StridedArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {StridedArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( StridedArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = StridedArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 08ffb8c..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var StridedArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like value. -* -* @param {NonNegativeInteger} N - number of values to stream -* @param {Collection} buffer - source value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Options} [options] - stream options -* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {StridedArrayStream} Stream instance -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* -* function log( v ) { -* console.log( v ); -* } -* -* var arr = new Float64Array( 10 ); -* var i; -* for ( i = 0; i < arr.length; i++ ) { -* arr[ i ] = randu(); -* } -* -* var stream = objectMode( arr.length, arr, 1, 0 ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( N, buffer, stride, offset, options ) { - var opts; - if ( arguments.length > 4 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MH2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new StridedArrayStream( N, buffer, stride, offset, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 72c2119..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.sep] - separator used to join streamed data -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings` -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming -* @param {Function} [options.serialize] - custom serialization function -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'objectMode': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1MH2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MH2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MH2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MH7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MH4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MH6p', 'serialize', opts.serialize ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index f25e483..3a48e0c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a strided array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "debug": "^2.6.9", - "readable-stream": "^2.1.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/streams-node-inspect-sink": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..255963a --- /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.factory.js b/test/test.factory.js deleted file mode 100644 index 0d8d995..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,376 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var StridedArrayStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var createStream = factory( value ); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory({ - 'highWaterMark': value - }); - createStream( 3, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory(); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var arr; - var i; - - createStream = factory( {} ); - arr = [ 1, 2, 3 ]; - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( arr.length, arr, 1, 0 ) instanceof StridedArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3cb29b9..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var stridedArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof stridedArrayStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof stridedArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index f51d542..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Readable = require( 'readable-stream' ).Readable; -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var parseJSON = require( '@stdlib/utils-parse-json' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var stridedArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the second argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, value, 1, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer for the third argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer for the fourth argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (number of elements; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( value, [ 1, 2, 3 ], -1, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (positive stride)', function test( t ) { - var values; - var i; - - values = [ - 3, - 4, - 5, - 6, - 7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (negative stride)', function test( t ) { - var values; - var i; - - values = [ - -3, - -4, - -5, - -6, - -7 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 2, [ 1, 2, 3 ], value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; positive stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided strided array parameters which are incompatible with a provided array-like object (offset; negative stride)', function test( t ) { - var values; - var i; - - values = [ - 20, - 30, - 40, - 50 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 1, [ 1, 2, 3 ], -1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - 'abc', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0, { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = new StridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var StridedArrayStream = stridedArrayStream; - var s; - - s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = stridedArrayStream( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned stream provides a method to destroy a stream (object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy({ - 'message': 'beep' - }); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream (error object)', function test( t ) { - var count = 0; - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error( 'beep' ) ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = stridedArrayStream( 8, [ 1, 2, 3, 4, 5, 6, 7, 8 ], 1, 0 ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (array)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - } - - function onEnd() { - var i; - - t.pass( 'stream ended' ); - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), expected[ i ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 7, 5, 3, 1 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( 4, values, -2, 6, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (large array)', function test( t ) { - var iStream; - var result; - var count; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - s.pipe( iStream ); - - function inspect( chunk ) { - count += 1; - t.equal( isBuffer( chunk ), true, 'returns a buffer' ); - result += chunk.toString(); - if ( count === 10 ) { - s.destroy(); - } - } - - function onClose() { - var i; - - t.pass( 'stream closed' ); - - result = result.split( '\n' ); - t.equal( result.length >= 10, true, 'has expected length' ); - for ( i = 0; i < 10; i++ ) { - t.equal( typeof parseFloat( result[ i ] ), 'number', 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; large array)', function test( t ) { - var iStream; - var opts; - var arr; - var s; - var i; - - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( i ); - } - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( arr.length, arr, 1, 0, opts ); - s.on( 'close', onClose ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - i = -1; - s.pipe( iStream ); - - function inspect( v ) { - i += 1; - t.equal( typeof v, 'number', 'returns expected value. i: '+i+'.' ); - if ( i === 10 ) { - return s.destroy(); - } - } - - function onClose() { - t.pass( 'stream closed' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'sep': '\n' - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a strided array-like object (object mode; empty)', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = []; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect() { - t.ok( false, 'should not be called' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which streams newline-delimited values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = values.slice(); - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '--++--' - }; - s = stridedArrayStream( values.length, values, -1, values.length-1, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( opts.sep ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'by default, the constructor returns a stream which serializes streamed values as JSON strings', function test( t ) { - var iStream; - var result; - var values; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var v; - var i; - - result = result.split( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (string)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return 'v::' + v.toString(); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom serialization function (buffer)', function test( t ) { - var expected; - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ - 'v::1', - 'v::2', - 'v::3', - 'v::4', - 'v::5', - 'v::6', - 'v::7', - 'v::8' - ]; - - opts = { - 'serialize': serialize - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - s.pipe( iStream ); - - function serialize( v ) { - return string2buffer( 'v::' + v.toString() ); - } - - function inspect( chunk ) { - result += chunk.toString(); - } - - function onEnd() { - var i; - result = result.split( '\n' ); - t.equal( result.length, expected.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'in object mode, `null` values are reserved', function test( t ) { - var iStream; - var values; - var count; - var opts; - var FLG; - var s; - - values = [ 1, 2, 3, null, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true - }; - s = stridedArrayStream( values.length, values, 1, 0, opts ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream.objectMode( inspect ); - - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v, i ) { - count += 1; - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onError( err ) { - FLG = true; - t.ok( false, err.message ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.equal( FLG, false, 'stream does not emit an error' ); - t.equal( count, 3, 'streamed expected number of values' ); - t.end(); - } -}); - -tape( 'by default, when not in object mode, a stream emits an `error` upon encountering an `undefined` value', function test( t ) { - var iStream; - var values; - var result; - var count; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - s = stridedArrayStream( values.length, values, 1, 0 ); - s.on( 'error', onError ); - s.on( 'end', onEnd ); - - iStream = inspectStream( inspect ); - - result = ''; - count = 0; - FLG = false; - s.pipe( iStream ); - - function inspect( v ) { - count += 1; - result += v.toString(); - } - - function onError( err ) { - FLG = true; - t.ok( true, err.message ); - } - - function onEnd() { - var j; - var i; - - t.pass( 'stream ended' ); - t.equal( FLG, true, 'stream does emit an error' ); - t.equal( count, 7, 'streamed expected number of values' ); - - result = result.split( '\n' ); - t.equal( result.length, 7, 'has expected length' ); - - j = -1; - for ( i = 0; i < values.length; i++ ) { - if ( values[ i ] === void 0 ) { - continue; - } - j += 1; - t.equal( parseFloat( result[ j ] ), values[ i ], 'returns expected value. i: '+i+'.' ); - } - t.end(); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index c8b73ab..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var StridedArrayStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object as a second argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided an integer as a third argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if not provided a nonnegative integer as a fourth argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, value ); - }; - } -}); - -tape( 'if provided an invalid readable stream option, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - objectMode( 3, [ 1, 2, 3 ], 1, 0, { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0 ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( 3, [ 1, 2, 3 ], 1, 0, {} ); - t.equal( s instanceof StridedArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which streams elements of an array-like object', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - s = objectMode( values.length, values, 1, 0 ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); - -tape( 'the function does not support overriding the `objectMode` option', function test( t ) { - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4 ]; - - opts = { - 'objectMode': false - }; - s = objectMode( values.length, values, 1, 0, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0c1b050..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,241 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `encoding` option which is neither a string nor `null`', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'encoding': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `sep` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'sep': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `serialize` option which is not a function', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - void 0, - null, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'serialize': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'objectMode': true, - 'highWaterMark': 64, - 'encoding': null, - 'sep': '\n', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - options = { - 'objectMode': false, - 'highWaterMark': 64, - 'encoding': 'utf8', - 'sep': '\t', - 'serialize': serialize - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); - - function serialize( v ) { - return v.toString(); - } -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -});